[concurrency-interest] AutomicBoolean toggleAndGet()

Guy Korland gkorland at gmail.com
Fri Feb 12 11:34:52 EST 2010


Leaving aside the fact that it completes the AtomicX API.
toggleAndGet() is a more natural to concurrent algorithms that are based on
a toggle bit. E.g. diffracting tree, counting network & etc.

Regards,
Guy Korland
@g_korland

On Fri, Feb 12, 2010 at 6:19 PM, Martin Buchholz <martinrb at google.com>wrote:

> AtomicBoolean.toggleAndGet() does seem plausible,
> although no obvious use case occurs to me.
> But it doesn't buy you much.
> Besides a cas loop on AtomicBoolean,
> you could also use
>
> (atomicInteger.incrementAndGet() & 0x1) == 0
>
> so without more motivation
> I'd be inclined to leave it out.
>
> Martin
>
> On Fri, Feb 12, 2010 at 06:59, Guy Korland <gkorland at gmail.com> wrote:
> > Hi,
> > AtomicBoolean.toggleAndGet() and getAndToggle()
> > It seems like a very usable feature to add to AtomicBoolean and something
> > that matchs the other AtomicX classes API (incrementAndGet).
> > Is there any reason why this class was discriminated?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20100212/89b7db43/attachment.html>


More information about the Concurrency-interest mailing list