concurrency

Craig Black cblack at ara.com
Tue Feb 5 07:08:43 PST 2008


"Christopher Wright" <dhasenan at gmail.com> wrote in message 
news:fo8o62$2m1t$1 at digitalmars.com...
> Craig Black wrote:
>> In that case, it may be beneficial to somehow separate parallel and 
>> sequential events, perhaps with separate event queues.  However, it would 
>> require that each event knows whether it is "pure" or not, so that it is 
>> placed on the appropriate queue.
>
> A static if or two in the event broker would solve it. There would be a 
> method:
> void subscribe (T)(EventTopic topic, T delegate) {
>    static assert (is (T == delegate));
>    static if (is (T == pure)) {
>       // add to the pure event subscribers for auto parallelization
>    } else {
>       // add to the impure ones
>    }
> }
>
>> -Craig

It might not be as fancy as using static if, but it might be simpler to use 
overloading (if the syntax will support it).

void subscribe(EventTopic topic, void delegate() del)  { ... }
void subscribe(EventTopic topic, pure void delegate() del) { ... } 





More information about the Digitalmars-d mailing list