Concurrency in D
Minas Mina
minas_mina1990 at hotmail.co.uk
Wed Jun 27 15:34:50 PDT 2012
I have been "playing" latetly with std.concurrency and
core.thread. I like both, but they are entirely different
approaches to concurrency.
std.concurrency: Uses message passing. Does not allow passing of
mutable types.
core.thread: Essentially the same as the approach taken by Java.
1) Is one favoured over the other? I guess std.concurrency would
be, because it uses messages (and I recently read somewhere that
immutability + message passing = good thing). Well, my problem
about is, how can send mutable data to another thread? _Can_ I do
it? If not, how am I supposed to share data between them? Not
everything can be immutable right? For example I would like to
have a thread calculate the sum of the first half of an array
while another thread would calculate the other half, and I could
add the two results at the end.
2) What about core.thread? To do proper sync between threads in
core.thread, semaphore, mutexes and stuff like that are needed.
Are those "good practice" in D?
3) I have also read a bit about syncronized classes and shared
classes/structs, altough I didn't understand it too much (well I
didn't try too much to be honest).
For all those appoaches, which is the preffered?
For all those appoaches, which is the preffered for game
programming?
Thank you.
More information about the Digitalmars-d-learn
mailing list