[concurrency-interest] Adding a createIfAbsent() API?

Neal Gafter neal at gafter.com
Mon Aug 13 23:57:41 EDT 2007

On 8/13/07, Doug Lea <dl at cs.oswego.edu> wrote:
> It's about time to recycle this (that I first posted May 15, 2006):

>From an API point of view (i.e. the user of the API), the callback approach
is, in my opinion, a much neater solution to the problem. A few details make
it unappealing - for example the ExecutionException instead of Java's
ordinary exception checking (whatever the passed code can actually throw
should be known by the compiler to be thrown by the invocation of
createIfAbsent). My hope is that closures would make this approach more
appealing. However, this kind of API may be inappropriate for a concurrent
map unless the implementation is sometimes allowed to invoke the callable
and then discard the value (Doug's solution 1a). If the map is implemented
using locking, the lock must be held for an arbitrarily long time while the
callable is invoked. It may be very difficult to implement in a wait-free
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20070813/6c7791c6/attachment.html 

More information about the Concurrency-interest mailing list