Is it possible to use a C multi-threaded lib with D (multi-threading)?

David d at dav1d.de
Sun Jan 13 02:57:37 PST 2013


Am 12.01.2013 20:28, schrieb Robert M. Münch:
> On 2013-01-12 17:32:21 +0000, David said:
> 
>>> I understand that the ABI of D is C compatible, so I would expect that
>>> there shouldn't be any problems with threading as well.
>>
>> D uses pthread for core.Thread and core.sync.*
> 
> On all platforms?

IIRC only posix

>> I wouldn't mix core.Thread/std.parallelism/std.concurrency with C
>> threading.
> 
> Ok.
> 
>> Like calling a core.Thread.Thread from a threaded c callback,
>> but it might even work.
> 
> Maybe I just need to give it a try.
> 
>> I used std.parallelism together with stb_image.c to load images
>> concurrently into memory, worked very well!
> 
> Just to be sure that I understand this right. The C part is not
> multi-threaded in your case, right? So, you used D's threading in
> combination with some C code.

Yes, but make sure the C-code is threadsafe, before stb_image I was
using DevIL, kept segfaulting.




More information about the Digitalmars-d mailing list