[jboss-dev] compareAndSet variation

Vladimir Blagojevic vblagoje at redhat.com
Wed Feb 10 11:04:19 EST 2010


Sorry, I meant to say that if expected is equal to underlying value it is set to update value and 0 is returned. Otherwise return delta between actual underlying value and expected. 
    
On 2010-02-10, at 10:40 AM, David M. Lloyd wrote:

> This doesn't really make any sense - you're saying if the value is different, return the delta and leave the value unchanged, but if the delta was zero between the expect and update, then the value wouldn't need changing anyway!  You can do that with just a read.
> 
> - DML
> 
> On 02/10/2010 09:36 AM, Vladimir Blagojevic wrote:
>> Hi,
>> 
>> Not sure if there are any concurrency enthusiasts here but I'll give it a shot :)
>> 
>> Would it be possible to make a lock-free, thread safe structure that would essentially retain "boolean compareAndSet(long  expect,long  update)" semantics but instead of returning boolean would return delta between actual underlying value and update value? Delta of zero would therefore mean that value has been set.
>> 
>> Vladimir
>> 
>> 
>> 
>> 
>> _______________________________________________
>> jboss-development mailing list
>> jboss-development at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/jboss-development





More information about the jboss-development mailing list