[OT] Re: C's Biggest Mistake on Hacker News
Ali Çehreli
acehreli at yahoo.com
Sat Jul 28 22:56:39 UTC 2018
On 07/28/2018 05:43 AM, Laeeth Isharc wrote:
> It's not that bad calling D from Java.
Running D's GC in a thread that is started by an external runtime (like
Java's) can be problematic. If a D function on another D-runtime thread
needs to run a collection, then it will not know about this Java thread
and won't stop it. One outcome is a crash if this thread continues to
allocate while the other one is collecting.
The solution is having to call thread_attachThis() upon entry to the D
function and thread_detachThis() upon exit. However, there are bugs with
these function, which I posted a pull request (and abandoned it because
of 32-bit OS X test failures.)
I think a better option would be to forget about all that and not do any
GC in the D function that is called from Java. This simple function
should just send a message to a D-runtime thread and return back to Java.
Ali
More information about the Digitalmars-d
mailing list