How do I have multiple threads (of same Thread class) call a delegate on multiple objects?

Enjoys Math via Digitalmars-d digitalmars-d at
Fri Aug 25 07:06:39 PDT 2017

I have a struct A:

struct A {
   this () {
       b = new B();
       b.connect(& receive);

   void receive();


a thread class

class B : Thread {

    this() {
       onEvent = null;
       super(& run);

    void connect (void delegate eventHandler) {
       onEvent = eventHandler;

    void run() {
        while (true) {
          // ...
          // ...

    void delegate() onEvent;

The result is that receive() is only getting called for the 
last-most A that was intialized, although run() I've verified is 
being called on all the right instances of B.

I've tried the exact same set up with std.signals and currying 
the delegate through a class ReceiveEvent since structs can't 
receive signals.  The exact same thing happened.

Can't figure this one out...

I've tried passing a void* pointer to A along with the delegate 
and that did nothing.


More information about the Digitalmars-d mailing list