GetAndSet function (corresponding to cas function)
Andrew Wiley
wiley.andrew.j at gmail.com
Mon Dec 26 13:06:57 PST 2011
On Mon, Dec 26, 2011 at 2:34 PM, Adrian Mercieca <amercieca at gmail.com> wrote:
> Hi folks,
>
> Would anyone answer me on this please?
>
> To clarify, in Java there is are getAndSet methods on Atomic type objects
> (along with compareAndSet).
>
> I know that in D there is the cas function (equivalent to Java's
> compareAndSet); is there an equivalent D function for Java's getAndSet
> please?
>
>
> Thanks.
>From Java:
---
public final boolean getAndSet(boolean newValue) {
for (;;) {
boolean current = get();
if (compareAndSet(current, newValue))
return current;
}
}
---
getAndSet is just a wrapped version of compareAndSet.
More information about the Digitalmars-d-learn
mailing list