Is it possible to use a C multi-threaded lib with D (multi-threading)?
Robert M. Münch
robert.muench at saphirion.com
Sun Jan 13 06:46:39 PST 2013
On 2013-01-13 00:35:51 +0000, Kapps said:
> If you're using a thread created from a C library, and it uses the GC,
> you'll need to call thread_attachThis
> (http://dlang.org/phobos/core_thread.html#.thread_attachThis) on each
> thread that uses it so that the GC knows to suspend the thread during a
> collection. If you don't do this, you'll get random segfaults and other
> issues.
Not sure I understand. I assume you mean by "create a thread from a C
library" creating a D thread? My idea was that a C thread isn't using
the GC, only D code does.
I have it the other way: D main program, which starts C threads. And
yes the C code is thread safe.
--
Robert M. Münch
Saphirion AG
http://www.saphirion.com
smarter | better | faster
More information about the Digitalmars-d
mailing list