On Wednesday, 19 February 2014 at 16:23:36 UTC, Bienlein wrote:
Hello,

I was wondering whether it can be done somehow to select on a delegate in the receive block when spawning a thread:


void spawnedFunc(Tid tid)
{
    // Receive a message from the owner thread.
    receive(
        (int i) { writeln("Received the number ", i);}
        (delegate d) { writeln("Receiving a delegate");}      
    );
}

int delegate() dg;

void main()
{
  // Start spawnedFunc in a new thread.
  auto tid = spawn(&spawnedFunc, thisTid);

  // Send the number 42 to this new thread.
  send(tid, 42);

  int a = 7;
  int foo() { return a + 3; }
  dg = &foo;

  send(tid, dg);
}

My solution of course doesn't compile.
Thanks for any hint, Bienlein

Not helpful right now, but maybe interesting to you: http://forum.dlang.org/post/olhrismoxqybbcfuj...@forum.dlang.org

Reply via email to