-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Using ThreadLocal Digester for NameBasedGenerator to avoid synchronized #88
base: master
Are you sure you want to change the base?
Conversation
General idea sounds reasonable, but I am not so sure about specific implementation. I suspect it'd be safer to use separate implementation with separate accessor for generator: keeping One future challenge is that |
{ | ||
while (--rounds >= 0) { | ||
final CyclicBarrier gate = new CyclicBarrier(11); | ||
final MessageDigest digester = MessageDigest.getInstance("SHA-1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "SHA-1"
can be declared as a constant
/** | ||
* Method for generating name-based UUIDs using specified name (serialized to | ||
* bytes using UTF-8 encoding). No synchronization is performed on digester. | ||
* Digester is assumed to be created with ThreadLocal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It will be better if we can provide an use-case example when we should use this method.
/** | ||
* Method for generating name-based UUIDs using specified byte-serialization | ||
* of name. No synchronization is performed on digester. Digester is assumed | ||
* to be created with ThreadLocal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, can we put an example when to use this method
Hi, does it make sense to create a non synchronized version of NameBasedGenerator if the user knows the digester is thread safe? With my M1, the synchronized is about 40% more in a 10 threads scenario.