Wait-free thread communication

Andy Smith via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 9 06:20:18 PST 2016

On Friday, 8 January 2016 at 16:58:59 UTC, Jin wrote:
> Idea: no mutex, no CAS, only one direction queues without any 
> locks.
> My prototype (https://github.com/nin-jin/go.d) is up to 10x 
> faster than std.concurrency.send/receive
> ---
> writers =512
> readers =1
> std.concurency milliseconds=1313
> jin.go milliseconds=113
> ---
> Realization:
> Queue! - buffered static typed channel. One and only one thread 
> can push data to queue, and one and only one can take data from 
> queue. Thread blocks when he takes from empty queue and pushes 
> to fulfilled queue.
> Queues! - list of queues with round robin balancing
> go! - starts new thread, in future i want to implement 
> something like goroutine, but i do not understand how yet.
> I need some good advice, i am newbie in D :-)
> Problems:
> For blocking thread i use loop with Thread.sleep - this is bad 
> decision IMHO.
> On my system i can create only up to 1000 threads without 
> errors. Fibers from core.thread or Tasks from std.parallelism 
> potentiaĞ´ly can resolve this problem, but how to integrate 
> their gracefully.
> API of jin-go can be better?
> Which dub modules can help me?

I'm a little worried you have no volatile writes or fences around 
your code when you 'publish' an event using head/tail etc. It 
looks like it's working but how are you ensuring no compiler/CPU 
reordering is ocurring. Does x86_64 actually allow you to get 
away with this? I know its memory model is stricter than others...



More information about the Digitalmars-d mailing list