Re: Druntime and non-D threads

2017-12-12 Thread Ali Çehreli via Digitalmars-d
On 12/11/2017 07:18 PM, Joakim wrote: > On Friday, 8 December 2017 at 09:33:03 UTC, Ali Çehreli wrote: >> I failed to find a way for Druntime to be resilient when such threads >> disappear. For example, the registered cleanup handler in thread.d is >> called only for cancelled threads, not the

Re: Druntime and non-D threads

2017-12-11 Thread Joakim via Digitalmars-d
On Friday, 8 December 2017 at 09:33:03 UTC, Ali Çehreli wrote: I'm trying to use D as a library to be called from a non-D environment e.g. Java runtime. If I'm not mistaken, it's quite difficult and perhaps impossible to use GC in such a scenario. It works as long as attached threads don't go

Re: Druntime and non-D threads

2017-12-11 Thread Ali Çehreli via Digitalmars-d
On 12/11/2017 08:58 AM, Mengu wrote: > On Monday, 11 December 2017 at 16:25:42 UTC, Ali Çehreli wrote: >> On 12/08/2017 02:54 AM, Nemanja Boric wrote: >>> [...] >> >> So, in cases where D is just a portable library, the only sane thing >> to do seems to be what Kagamin suggested: create a D

Re: Druntime and non-D threads

2017-12-11 Thread Mengu via Digitalmars-d
On Monday, 11 December 2017 at 16:25:42 UTC, Ali Çehreli wrote: On 12/08/2017 02:54 AM, Nemanja Boric wrote: [...] So, in cases where D is just a portable library, the only sane thing to do seems to be what Kagamin suggested: create a D thread and send requests to it. That way, we would

Re: Druntime and non-D threads

2017-12-11 Thread Ali Çehreli via Digitalmars-d
On 12/08/2017 02:54 AM, Nemanja Boric wrote: On Friday, 8 December 2017 at 09:33:03 UTC, Ali Çehreli wrote: 5) We depend on SIGUSR1 (and SIGUSR2, which may not be necessary but it's a different topic) to suspend non-D threads. Does that work with all threads? What if the calling framework has

Re: Druntime and non-D threads

2017-12-11 Thread Ali Çehreli via Digitalmars-d
On 12/08/2017 04:23 AM, Guillaume Piolat wrote: >> Every D api call must call thread_attachThis > I advise to make a RAII struct you will put in any accessible callback, which deals with this Of course. :) That's how I've been trying to use. > IMHO thread_detachThis *must* be called at

Re: Druntime and non-D threads

2017-12-11 Thread Ali Çehreli via Digitalmars-d
On 12/08/2017 02:53 AM, Kagamin wrote: You can create a D thread an send request to it. That's a good idea. Thanks. Ali

Re: Druntime and non-D threads

2017-12-08 Thread Guillaume Piolat via Digitalmars-d
On Friday, 8 December 2017 at 09:33:03 UTC, Ali Çehreli wrote: One idea was to attach and detach in every api function something to the effect of extern(C) my_api_func() { thread_attachThis(); scope(exit) thread_detachThis(); // Do work, potentially producing garbage... } Does

Re: Druntime and non-D threads

2017-12-08 Thread Nemanja Boric via Digitalmars-d
On Friday, 8 December 2017 at 09:33:03 UTC, Ali Çehreli wrote: 5) We depend on SIGUSR1 (and SIGUSR2, which may not be necessary but it's a different topic) to suspend non-D threads. Does that work with all threads? What if the calling framework has other uses for those signals? Would we be

Re: Druntime and non-D threads

2017-12-08 Thread Kagamin via Digitalmars-d
You can create a D thread an send request to it.