A thread without GC

Adam D. Ruppe destructionator at gmail.com
Mon Jul 8 08:08:15 PDT 2013


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.


More information about the Digitalmars-d mailing list