Multiple signals using std.signal

Christopher Nicholson-Sauls ibisbasenji at gmail.com
Sat Jan 22 13:22:04 PST 2011


On 01/22/11 12:45, Mandeep Singh Brar wrote:
> Hi,
> 
> Is it possible for a class to emit multiple types of signals using
> std.signal. e.g. SignalA, SignalB etc.
> 
> Also i believe that emit method emits signals synchronously. Is it
> possible to emit method asynchronously.
> 
> Thanks
> Mandeep

Use mixin naming to provide multiple signals, like so:

    class Foo {
        mixin Signal!(int, int) signalA;
        mixin Signal!(int, string) signalB;
    }

Emit with signalA.emit(), connect with signalA.connect(), etc.  For the
latter question: I don't think so without redesigning the std.signals
module, which is probably worth filing an enhancement request for.

-- Chris N-S


More information about the Digitalmars-d-learn mailing list