Concurrency

Sean Kelly sean at invisibleduck.org
Sun Jul 25 21:18:29 PDT 2010


Graham St Jack Wrote:

> However, I have had some problems with std.concurrency (most of which 
> I'm sure are already being addressed by Sean). In particular, I wanted a 
> way to select on multiple file-descriptors so that I could (say) send 
> commands to a thread that also reads from a blocking file-descriptor 
> like a serial port, UDP socket or GTK main loop.

Hm... this is essentially what libev and libevent do.  The trick is mostly making this work in a consistent and performant manner on both Posix and Windows.  On Posix, the read event simply tells you data is available, while on Windows the read event hands the data to you directly.  The former works quite well with messaging while the latter... well, it's kind of weird.

I like that you're playing with Channels, by the way.  I chose the messaging API in std.concurrency because it can have a range of more structured models built on top of it, so I think it's more likely to see broad use done this way.  Maybe channels will be the first :-)


More information about the Digitalmars-d mailing list