shared std.signals
Joshua Niehus
jm.niehus at gmail.com
Tue Jan 22 23:11:57 PST 2013
Is it possible to create a shared signal class?
I would like to create a shared signal class so some other
process that knows certain things can come along emit its info to
any observer:
import std.stdio, std.signals;
class Observer {
void watch(string msg) {
writeln(msg);
}
}
class Foo {
string value() {
return _value;
}
string value(string v) {
if (v != _value) {
_value = v;
emit(_value);
}
return v;
}
mixin Signal!(string);
private:
string _value;
}
shared Foo a;
void main() {
a = new shared Foo();
Observer o1 = new Observer();
a.connect(&o1.watch);
}
More information about the Digitalmars-d-learn
mailing list