Using ThreadLocal Digester for NameBasedGenerator to avoid synchronized#88
Using ThreadLocal Digester for NameBasedGenerator to avoid synchronized#88magnoyu wants to merge 2 commits intocowtowncoder:mainfrom
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.
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.
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.
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.