Skip to main content
7 events
when toggle format what by license comment
Aug 9, 2016 at 12:10 comment added Jean-Philippe Pellet For those looking for Viktor's implementation, you can find it as akka.util.ConcurrentMultiMap. Thanks a lot, Viktor!
Sep 3, 2010 at 14:00 comment added Viktor Klang Good idea Rex, I'll try that approach and see if it works out.
Sep 3, 2010 at 13:50 comment added Rex Kerr Can you tolerate locking the queue when you get it, and then holding the queue while you send an update to the map to empty that (k,v) pair? That is, use the lock on the queue rather than on the whole map to avoid collisions? (And add logic to handle the case where you get a queue but then, before you can lock it, it's emptied out and removed from the map--all you have to do is check when you get the lock that it is non-empty. If it is empty, assume it's been removed.)
Sep 3, 2010 at 13:49 comment added Jon Freedman This may be the best solution, you can constrain locking the entire collection to only occur when you find a Queue which is empty, I'm not sure you can get away from either writing your own implementation, or changing the way you want to use this to handle this nested structure rather than a Multimap.
Sep 3, 2010 at 13:45 comment added Viktor Klang Can't leave the queue since it will leak memory. I'm actually considering using the ConcurrentHashMap source and bend it to my will, but it seems like a very crude approach.
Sep 3, 2010 at 13:42 comment added Rex Kerr @Viktor - If you have the (key,value) pair, map.get(key).remove(value) should do the trick as long as you leave the empty queue there as a placeholder when you remove a key and catch the exception if it's not there (including the NPE off of get). If you can't leave the queue as a placeholder, then it's difficult to ensure safety unless you do lock the entire map while you clean out the cruft.
Sep 3, 2010 at 13:22 history answered Rex Kerr CC BY-SA 2.5