The claim is on a long with a check before increment.

On Tuesday, 30 May 2017 11:25:50 UTC+1, Peter Veentjer wrote:
>
> Thanks everyone.
>
> Another related question. When an atomic integer is used so that writers 
> can claim their segment in the buffer, what prevent wrapping of this atomic 
> integer and falsely assuming you have allocated a section in the buffer?
>
> So imagine the buffer is full, and the atomic integer > buffer.length. Any 
> thread that wants to write, keeps increasing this atomic integer far far 
> beyond its maximum capacity of the buffer. Which in itself is fine because 
> one can detect what kind write failure one had:
> - first one the over commit
> - subsequent over commit
>
> But what if the value wraps? In theory one could end up thinking one has 
> claimed a segment of memory still needed for reading purposes.
>
> One simple way to reduce the problem is to use an atomic long instead of 
> an atomic integer.
>

-- 
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to