On Monday, 8 July 2013 at 14:53:25 UTC, John Colvin wrote:
I wonder if one could somehow register a pre-existing thread with std.concurrency, being careful not to introduce any reference that lets in the garbage collector.

There is a thread_attachThis() in core.thread that "Registers the calling thread for use with the D Runtime. " and returns a Thread object.

However, I think that registers it with the GC too so it defeats the purpose of skipping Thread in the first place.

Looking at the source of std.concurrency, it looks like it just has a thread local mailbox for each one, that is created when you call thisTid() the first time.

idk if that's actually all that is done, or if TLS needs any special work (I've never actually used pthreads directly), but maybe you could try calling that thisTid() function in the thread you make yourself and then send it a message and see what happens.

Reply via email to