www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - External threads calling into D code

reply "George Sapkin" <george.sapkin gmail.com> writes:
So, me and my threads again :)

I have some threads being created by libuv using start_thread() 
from libpthread calling into D code. D code (after some help from 
this forum) has been properly shared and when called from D 
threads and tasks works correctly. However when called by libuv 
from outside throws a segmentation fault when creating new 
dynamic array above certain size. The signal is from 
gc.Gcx.fullcollect() from libphobos2.

I've figured that could be caused by GC not being enabled in 
threads not managed by D runtime, so I tried to GC.enable() when 
in a new thread and now it seems to work. Is that expected 
behavior and a correct solution? Thanks.
Jun 17 2014
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 06/17/2014 06:43 PM, George Sapkin wrote:
 So, me and my threads again :)

 I have some threads being created by libuv using start_thread() from
 libpthread calling into D code. D code (after some help from this forum)
 has been properly shared and when called from D threads and tasks works
 correctly. However when called by libuv from outside throws a
 segmentation fault when creating new dynamic array above certain size.
 The signal is from gc.Gcx.fullcollect() from libphobos2.

 I've figured that could be caused by GC not being enabled in threads not
 managed by D runtime, so I tried to GC.enable() when in a new thread and
 now it seems to work. Is that expected behavior and a correct solution?
 Thanks.
Without any experience on this topic, I suspect this is what you need: http://dlang.org/phobos/core_thread.html#.thread_attachThis Ali
Jun 17 2014
parent "George Sapkin" <george.sapkin gmail.com> writes:
On Wednesday, 18 June 2014 at 02:35:03 UTC, Ali Çehreli wrote:
 Without any experience on this topic, I suspect this is what 
 you need:

   http://dlang.org/phobos/core_thread.html#.thread_attachThis

 Ali
That was exactly what I needed. Thanks.
Jun 17 2014