Thread overview
shared std.signals
Jan 23, 2013
Joshua Niehus
Jan 23, 2013
Joshua Niehus
Jan 23, 2013
Jonathan M Davis
January 23, 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);
}
January 23, 2013
On Wednesday, 23 January 2013 at 07:11:59 UTC, Joshua Niehus wrote:
> Is it possible to create a shared signal class?

oh god... dont tell me __gshared !
Think i answered my own question, it got me to the next step.  going to have to read through those giant "shared" threads again

January 23, 2013
On Wednesday, January 23, 2013 08:17:57 Joshua Niehus wrote:
> On Wednesday, 23 January 2013 at 07:11:59 UTC, Joshua Niehus
> 
> wrote:
> > Is it possible to create a shared signal class?
> 
> oh god... dont tell me __gshared !
> Think i answered my own question, it got me to the next step.
> going to have to read through those giant "shared" threads again

shared still needs to be sorted out. The basic idea is solid, but the details need work. Right now, you basically have to cast it to thread-local all over the place to do much of anything with shared variable (obviously requiring that you protect that code with a mutex or synchronized block or whatnot so that it's thread-safe). It's not clear at this point what exactly we're going to do to improve shared.

- Jonathan M Davis