On Tuesday, 18 February 2014 at 21:05:38 UTC, Nordlöw wrote:
What's the best solution to communicate between threads in D today if I care about

1. Security & Correctness?
2. Performance?

and are these mutually exclusive?

Does Phobos or other library contain lockfree queues?

From what I can see std.concurrent.MessageBox requires Mutex-locking. Is this really needed or can it be enhanced to support lockfree communication similar to what Boost.Lockfree does?

Performance and inter-thread communication is heavily dependant on the use-case, including the details of memory access patterns etc. (cache misses can hurt you more than lock overheads ever will)

Most benchmarks that show amazing lock-free performance scaling deal with pathological cases. A lot of real-world code can be plenty fast (or even faster) with message-passing or (sometimes even) locks.


Security and correctness: message passing wins here, no question. Data is copied between threads, no possibility of races etc. I really like std.concurrency for this: very intuitive, easy to use and pretty fast.

Reply via email to