www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Multiple signals using std.signal

reply Mandeep Singh Brar <mandeep brars.co.in> writes:
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
Jan 22 2011
parent Christopher Nicholson-Sauls <ibisbasenji gmail.com> writes:
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
Jan 22 2011