[concurrency-interest] Re : concurrent counter : incrementAndGet

Doug Lea dl at cs.oswego.edu
Thu Aug 18 16:05:59 EDT 2011


On 08/14/11 07:03, Jeff Hain wrote:
>
> That could work well for some cases indeed, but I'm working on a sort
> of Disruptor, using the counter with modulo to pick up slots to write to in
> a cyclic array, monotonically, or non-monotonically but for a short time
> (for readers not to be blocked on a not-yet-written slot), and any writer
> can stop to work anytime; in this case I don't see how that could apply
> easily.

I don't think "non-monotonically but for a short time" makes
this easier, since any violations are likely to be unbounded.
You might be able to live with thread local random number generators,
so that in the long run on average you are balanced?
Otherwise, you have a version of the Counting problem described
in Herlihy & Shavit, for which all known scalable solutions
are expensive, complicated, and difficult to package as
j.u.c components. Although there are some special cases like
SNZI for detecting when counts hit the particular value of zero.

(This seems to be the main bottleneck in Disruptor-like designs.)

-Doug



More information about the Concurrency-interest mailing list