Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distributed message passing in D?

I really like the message passing primitives that D implements. I have only seen examples of message passing within a program though. Is there support for distributing the messages over e.g. a network?

like image 519
Tobias Furuholm Avatar asked Aug 12 '10 20:08

Tobias Furuholm


2 Answers

The message passing functions are in std.concurrency, which only deals with threads. So, the type of message passing used to pass messages between threads is for threads only. There is no RMI or anything like that in Phobos. That's not to say that we'll never get something like that in Phobos (stuff is being added to Phobos all the time), but it doesn't exist right now.

There is, however, the std.socket module which deals with talking to sockets, which is obviously network-related. I haven't used it myself, but it looks like it sends and receives void[]. So, it's not as nice as sending immutable objects around like you do with std.concurrency, but it does allow you to do network communication via sockets and presumably in a much nicer manner than if you were using C calls directly.

like image 55
Jonathan M Davis Avatar answered Oct 23 '22 14:10

Jonathan M Davis


Seems that this has been considered. From the Phobos documentation (found it through Jonathan M Davis answer)

This is a low-level messaging API upon which more structured or restrictive APIs may be built. The general idea is that every messageable entity is represented by a common handle type (called a Cid in this implementation), which allows messages to be sent to in-process threads, on-host processes, and foreign-host processes using the same interface. This is an important aspect of scalability because it allows the components of a program to be spread across available resources with few to no changes to the actual implementation.

Right now, only in-process threads are supported and referenced by a more specialized handle called a Tid. It is effectively a subclass of Cid, with additional features specific to in-process messaging.

like image 34
Tobias Furuholm Avatar answered Oct 23 '22 16:10

Tobias Furuholm