[concurrency-interest] conditional put

David Holmes dcholmes at optusnet.com.au
Mon Nov 5 23:05:46 EST 2007


Dave,

It is unclear from Dhanji's post exactly what level of "atomicity" is
required. However, if I presume that it is atomic with respect to being
added to the map, then locking would have to be done across the map
operations and that would defeat the purpose of using CHM.

Cheers,
David Holmes

> -----Original Message-----
> From: Dave Griffith [mailto:dgriffith at bellsouth.net]
> Sent: Tuesday, 6 November 2007 1:57 PM
> To: dholmes at ieee.org
> Cc: Dhanji R. Prasanna; concurrency-interest
> Subject: Re: [concurrency-interest] conditional put
>
>
> Just have the table (or some shadow table) contain either values or
> futures.  Lock the combined "table with either values or futures"
> structure on every access (accesses will be shortlived, and not
> require locking for the duration of the deferred calculation) and you
> should be good to go.  What am I missing?
>
> --Dave Griffith
>
> On Nov 5, 2007, at 9:49 PM, David Holmes wrote:
>
> > Dhanji,
> >
> > I can think of some ugly tricks to get the Callable evaluated only
> > if being
> > placed into (or potentially placed into) the map; but there is no
> > way to do
> > this "atomically".
> >
> > David Holmes
> >
> >> -----Original Message-----
> >> From: concurrency-interest-bounces at cs.oswego.edu
> >> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of
> >> Dhanji
> >> R. Prasanna
> >> Sent: Tuesday, 6 November 2007 12:28 PM
> >> To: concurrency-interest
> >> Subject: [concurrency-interest] conditional put
> >>
> >>
> >> Hi,
> >>
> >> CHM is a wonderful abstraction for atomic conditional puts
> >> (putIfAbsent). However, it does not work well in a lambda-like use
> >> case (i.e. evaluate if absent).
> >>
> >> Is there some way for me to achieve the following:
> >>
> >> chm.putIfAbsent(key, new Callable<Value> {
> >>     //expression that is only evaluated if key is absent
> >> });
> >>
> >> And that this callable is evaluated atomically.
> >> Thank you,
> >>
> >> Dhanji.
> >> _______________________________________________
> >> Concurrency-interest mailing list
> >> Concurrency-interest at altair.cs.oswego.edu
> >> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
> > _______________________________________________
> > Concurrency-interest mailing list
> > Concurrency-interest at altair.cs.oswego.edu
> > http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
>



More information about the Concurrency-interest mailing list