www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - spawning a thread in a class

reply "Mike James" <foo bar.com> writes:
I have some old serial comms code written in D1 + Tango and I'm going 
through the process of re-writing it for D2 + Phobos. The old code used 
Thread from the Tango library...

private Thread rxThread;
...
open() {
   ...
    rxThread = new Thread(&rxHandler);
    rxThread.start();
    ...
}

private rxHandler() {
    ...
}

The comms class worked fine (although I only ever used as 1 instance :-) )

I'm using the std.concurrency in Phobos to do the threading in the new 
version but I'm having problems passing the address of the receive handler. 
Are there any solutions to this - without making the receive handler static 
or outside the class :-)

Thanks.

-=mike=-
Jul 21 2010
parent Sean Kelly <sean invisibleduck.org> writes:
Mike James Wrote:
 
 I'm using the std.concurrency in Phobos to do the threading in the new 
 version but I'm having problems passing the address of the receive handler. 
 Are there any solutions to this - without making the receive handler static 
 or outside the class :-)
Not at the moment, though I suppose one could argue that spawn() should accept shared delegates. I have to update Thread to accept these either way.
Jul 21 2010