Wait-free thread communication

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 10 13:29:18 PST 2016


On 01/09/2016 04:51 PM, Jin wrote:
> I just add atomic fence for push and take:
> 
>         this.messages[ this.tail ] = value;
>         atomicFence;
>         this.tail = ( this.tail + 1 ) % this.size;

Don't do this, memory fences are expensive.

This is what you need for a spsc queue.
https://github.com/MartinNowak/lock-free/commit/233739262c14e00866a60f4a6a86c1b979ac968b


More information about the Digitalmars-d mailing list