'importing' threads — i.e. thread_attachThis()
    Cauterite via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Fri Aug 12 03:45:22 PDT 2016
    
    
  
I'm planning on 'importing' a thread into the D runtime using 
thread_attachThis(), and was just wondering about the potential 
pitfalls of this process. For example:
- Would having an entry function other than 
core.thread.thread_entryPoint() pose problems? What about during 
stack unwinding? Should I try to replicate the exception handling 
code of thread_entryPoint() in my own entry function?
- I'm aware of having to invoke rt_moduleTlsCtor() explicitly, 
but what about rt_moduleTlsDtor() ? Should I again follow 
thread_entryPoint()'s behaviour here?
- How important is it to run the thread though _beginthreadex() ? 
I know the Microsoft CRT uses _beginthreadex()/_threadstartex() 
to set up the thread's '_tiddata' object, but since D uses the 
Digital Mars _beginthreadex (which I don't have source for) I'm 
not entirely sure what goes on in there. It *appears* to be 
messing around with a global '__thdtbl' object.
- Do I need to call thread_detachThis() when the thread 
terminates, or can I just wait until the corresponding Thread 
object gets destroyed by the GC?
I'm using DMD on Windows x32 by the way.
Thanks for your help.
    
    
More information about the Digitalmars-d-learn
mailing list