Message passing pattern matching

Stanislav Blinov stanislav.blinov at gmail.com
Wed Jan 29 13:54:55 PST 2014


On Wednesday, 29 January 2014 at 21:50:28 UTC, Casper Færgemand 
wrote:
> A small example:
>
> while (true) {
>   receive(
>     (Tid tid, AddTid _) {some code}
>     (Tid tid, RemoveTid _) {some other code}
>     (string s) {broadcast stuff}
>   )
> }
>
> struct AddTid {}
> struct RemoveTid {}

 From where I sit that's a perfectly fine approach. After all, you 
do want to distinguish your own message types: any other 
std.concurrency-aware code (i.e. library) could pass its own 
messages. You wouldn't want to mistake those for your own private 
communication protocol.


More information about the Digitalmars-d-learn mailing list