Node.js async/threads and shared in D
George Sapkin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 11 09:07:50 PDT 2014
I have a Node.js module written in D and exposed through C++
interface. I'd like to implement a proper async API which is
pretty straightforward using libuv in the C++ glue part. On the D
side I have a data structure that's build once and then queried
from Node (possibly torn down and rebuild later). Since it will
be queried asynchronously, it will be called from multiple
threads. It is build using and stores inside a bunch of helper
classes. Am I correct to assume that for this data structure to
be available across threads it and every class it touches have to
be marked shared? What about types that I have no control of,
like arrays? Are they inherently shared?
I did read "Lock-Free Coding with shared classes" from TDPL, but
it has a rather short example and the structure there is both
read and written from multiple threads.
Thanks for any pointers.
More information about the Digitalmars-d-learn
mailing list