GC collecting "too much"..

simendsjo simendsjo at gmail.com
Mon Mar 26 11:15:40 PDT 2012


On Mon, 26 Mar 2012 17:10:34 +0200, Timon Gehr <timon.gehr at gmx.ch> wrote:

> On 03/26/2012 11:55 AM, simendsjo wrote:
>> It seems threads created in the c library is totally unknown to D. How
>> can I make D aware of these threads when there is no library support for
>> it?
>
> You may be looking for this:
> http://dlang.org/phobos/core_thread.html#thread_attachThis

Thanks, but I tried that too and couldn't get it to work.

I added the following:

extern(C) handler()
{
     synchronized // needed here to avoid the GC to collect while attaching  
thread?
     {
         if(!Thread.getThis()) // thread unknown to D
         {
             thread_attachThis();
             assert(Thread.getThis()); // now D knows about it
         }
     }
     GC.collect(); // still segfaults
}

Actually, using attachThis segfaults GC.collect() outside the thread  
handling code too.


More information about the Digitalmars-d-learn mailing list