performance - Closing over java.util.concurrent.ConcurrentHashMap inside a Future of Actor's receive method? -


i've actor want store mutable state inside map.

clients can send get(key:string) , put(key:string,value:string) messages actor.

i'm considering following options.

  1. don't use futures inside actor's receive method. in may have negative impact on both latency throughput in case i've large number of gets/puts because operations performed in order.
  2. use java.util.concurrent.concurrenthashmap , invoke gets , puts inside future.

given java.util.concurrent.concurrenthashmap thread-safe , providers finer level of granularity, wondering if still problem close on concurrenthashmap inside future created each put , get.

i'm aware of fact it's bad idea close on mutable state inside future inside actor i'm still interested know if in particular case correct or not?

in general, java.util.concurrent.concurrenthashmap made concurrent use. long don't try transport closure machine, , think through implications of being used concurrently (e.g. if read value, use function modify it, , put back, want use replace(key, oldvalue, newvalue) method make sure hasn't changed while doing processing?), should fine in futures.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -