www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.concurrency, or me?

reply Jesse Phillips <jessekphillips+D gmail.com> writes:
Reddit let me to this article walking through an example of Goroutines[1]. I
figured it could look about the same in D. So I set out to learn some
multi-threading. And what I ended up with[2] had an issue.

The mailbox size seems to be extremely small. Currently I have set the size to
10,000 and put a OnCrowding.throwException, though I wanted it to block,
changing it will result in a program that won't exit, and it will not have
finished processing all the calls. The last option of ignoring will result in
many calls not being finished.

This is tested no Linux, but I will test it on Windows tomorrow. I am running
it with:

./callcenter 3 10 10 10

which says, 3 agents, 10 calls, with a maximum of 10 secs to process a call,
and 10 ticks before creating the next call.

1. http://www.mprescient.com/journal/2011/1/9/concurrency-in-go-a-call-center-tutorial.html
2. https://gist.github.com/773979
Jan 10 2011
parent Jesse Phillips <jessekphillips+D gmail.com> writes:
I still haven't come to any conclusions, and made quite a mess trying to add on
work completed messages.

So I decided to make the next one[1] which uses the soon to be std.parallelism.

And the disappointment there is that parallel foreach doesn't seem to work with
a standard ForwardRange. Otherwise it works as expected.

1. https://gist.github.com/774983

Jesse Phillips Wrote:

 Reddit let me to this article walking through an example of Goroutines[1]. I
figured it could look about the same in D. So I set out to learn some
multi-threading. And what I ended up with[2] had an issue.
 
 The mailbox size seems to be extremely small. Currently I have set the size to
10,000 and put a OnCrowding.throwException, though I wanted it to block,
changing it will result in a program that won't exit, and it will not have
finished processing all the calls. The last option of ignoring will result in
many calls not being finished.
 
 This is tested no Linux, but I will test it on Windows tomorrow. I am running
it with:
 
 ./callcenter 3 10 10 10
 
 which says, 3 agents, 10 calls, with a maximum of 10 secs to process a call,
and 10 ticks before creating the next call.
 
 1. http://www.mprescient.com/journal/2011/1/9/concurrency-in-go-a-call-center-tutorial.html
 2. https://gist.github.com/773979
Jan 11 2011