Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pooled sequence generator #367

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

bserdar
Copy link
Contributor

@bserdar bserdar commented Jun 16, 2017

… tests

@dcrissman
Copy link
Member

What is a "pooled sequence generator"?

@bserdar
Copy link
Contributor Author

bserdar commented Jun 16, 2017 via email

@bserdar
Copy link
Contributor Author

bserdar commented Jun 16, 2017

#362

String fullName=coll.getFullName()+"."+name;
rwl.readLock().lock();
SequenceInfo si=sequenceInfo.get(fullName);
rwl.readLock().unlock();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that I understand the lock/unlock around Hash.get. What does that achieve?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Readers of the hashmap use readLock, writers use writeLock. So, many can read, only one can write. Readers will block when someone is writing, but readers won't block each other. Better than synchronized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

}
rwl.writeLock().unlock();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks more or less like a lazy instantiation. Would a synchronised method that returns a ReentrantReadWriteLock help clear some of this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is lazy initialization of a pool for the first time in the hashmap. To write into the hashmap, we need a writeLock. I don't understand your comment about the synchronized method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disregard then, based on other conversation thread.


try {
// If there are ids in the pool, use one
if(si!=null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it even possible for si to be null at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not, at this point, i'll clean that up

@bserdar bserdar changed the title WIP: pooled sequence generator--needs threading tests, needs metadata… Pooled sequence generator Jun 26, 2017
@bserdar
Copy link
Contributor Author

bserdar commented Jun 26, 2017

This is now ready for review-merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants