Actor model & D

Sean Kelly sean at invisibleduck.org
Tue Nov 5 07:45:14 PST 2013


On Nov 5, 2013, at 4:28 AM, "Bienlein" <jeti789 at web.de> wrote:
> 
>> On Monday, 19 August 2013 at 03:11:00 UTC, Luís Marques wrote:
>> Can anyone please explain me what it means for the D language to follow the Actor model, as the relevant Wikipedia page says it does? [1]
>> 
>> [1] http://en.wikipedia.org/wiki/Actor_model#Later_Actor_programming_languages
> 
> To my understanding "Message Passing Concurrency" in D is already
> very actor-like:
> 
> void main()
> {
>     Tid worker = spawn(&workerFunc, thisTid);
>     worker.send(1);
> }
> 
> void workerFunc(Tid owner)
> {
>     int value = 0;
>     value = receiveOnly!int();
>    writeln("value from parent: ", value);
> }
> 
> Sample code above taken from the book by Ali Çehreli and then
> simplified. This is such a breeze compared to spawning a thread
> in C++ or Java. Question is what happens when you spawn some
> thousand actors. I don't know whether the threads in D are made
> for this.

Threads in std.concurrency are currently all kernel threads. However, just yesterday I started working on a way to make that configurable by way of a user-defined Multiplexer class. The inspiration was to make it so message passing works with vibe.d so different logical threads could communicate. It seems like a pretty simple change so far, though I guess we'll see today. As a demo, I'm creating both a ThreadMultiplexer and a FiberMultiplexer. 


More information about the Digitalmars-d mailing list