[dmd-concurrency] Pattern matching on message receives, error handling

Mark Kegel mark.kegel at gmail.com
Wed Jan 13 18:41:27 PST 2010


I would suggest adding functionality to test and tell the user if they
have message handlers that will never be called as some previous
function may swallow all messages after some point. Also, it might be
nice to have a default handler templated to take some Varient type
that can handle dropped messages, if for nothing more than
logging/debugging purposes.

Mark

On Wed, Jan 13, 2010 at 2:11 PM, Sean Kelly <sean at invisibleduck.org> wrote:
> On Jan 13, 2010, at 11:06 AM, Kevin Bealer wrote:
>>
>> If I do this syntax:
>>
>> auto dg1 = void delegate(A x) { ... };
>> auto dg2 = void delegate(B x) { ... };
>>
>> receive(dg1, dg2);
>>
>> Does this mean receive anything that matches dg1, and if nothing is found, receive anything that matches dg2?  Or does it mean to take the first message in order that matches either one?
>
> The latter.  The implementation is basically this:
>
> foreach( m; message ) {
>    foreach( f; function ) {
>        if( argsMatch( m, f ) ) {
>            f( m );
>            dequeue( m );
>            return;
>        }
>    }
> }
>
> For dynamic pattern matching, the if test would be:
>
> if( argsMatch( m, f ) && f( m ) ) {
>    dequeue( m );
>    return;
> }
>
>
> _______________________________________________
> dmd-concurrency mailing list
> dmd-concurrency at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency
>


More information about the dmd-concurrency mailing list