Calling D library from other languages on linux using foreign threads

tchaloupka chalucha at gmail.com
Mon Mar 25 13:55:30 UTC 2019


On Saturday, 23 March 2019 at 17:33:31 UTC, tchaloupka wrote:
> I've no idea what should be done with C's main thread as it 
> can't be attached because it'll hang.
> In one of forum threads I've also read the idea to not using 
> foreign threads with GC but somehow delegate their work to D's 
> thread.
> Can this work somehow? But `new Thread()` would still be needed 
> to call from C side or static this() but from C's thread.

I've tried this approach here: 
https://github.com/tchaloupka/dlangsharedlib/tree/master/workaround.

I must say, it's an ugly and error prone hack.. :(

It seems to be working, but questions remain:
* is it ok to initialize D runtime and then use GC in the same C 
thread (to create worker Thread)?
* is this reliable?
* should foreign threads work with D's runtime at all?

In the current state, D's libs seems to be pretty useless to be 
used from other languages if GC is needed.


More information about the Digitalmars-d-learn mailing list