Proposal for a MessageQueue (was Re: public MessageBox)
Nathan M. Swan
nathanmswan at gmail.com
Thu Mar 22 18:35:04 PDT 2012
On Friday, 23 March 2012 at 00:14:00 UTC, Sean Kelly wrote:
> While sending messages like a bare string might be good for
> example code, any real application is going to use structured
> messages whose type is specific to what the message is for,
> contains fields like sender Tid, etc. It seems like you're
> aiming more for CSP where you'd create a separate communication
> channel per use. You could even fake it by wrapping
> send/receive with your own CSP-like API, though it's quite
> likely that a from-scratch CSP style implementation would be
> faster because there'd be no need to package messages.
I see your point. To make this easier, may I suggest:
T receiveNext(T)() {
T r;
receive((T t) {r = t;});
return r;
}
A big reason for the use of receiveOnly (in my code) is its
convenience. receiveNext, and a discouragement of using
receiveOnly, would be a simpler solution.
> Used to work, and std.concurrency doesn't even use std.utf.
> Not sure what's going on there.
Weird :(
NMS
More information about the Digitalmars-d
mailing list