Embedding Julia into multithreading apps

No, I didn’t mean from julia, but from C to Julia. Something like that: the user click on a button that dispatch a job to Julia thread and wait it to be finished.

It depends on what exactly you do I guess?

I mean, if you use some code to do thread sync yourself and never run any julia code on your thread, julia certainly won’t care where the requests come from.

The code from @cdsousa above seems decent though I didn’t read it through carefully. The only obvious issue I’ll complain about is that julia does not support being initialize and finalize multiple times so make sure you don’t contruct that class more than once in the lifetime of the program.


Thanks for the excellent code!
The question remains - is it necessary to perform all the functions of Julia that way (via Worker)?
or jl_box_xxx, jl_unbox_xxx families can be executed in parallel, without capturing the Workers` grand-lock ??

I actually don’t know that. I’ve just played a little with that code, and solely tried evaluating Julia code and nothing fancy from he Julia C API.

Don’t call any function in another thread. For unbox, you can just load from the pointer directly without calling any functions.

Have you looked at AsyncCondition? I think it can be used for C-to-Julia communication (but not to “wait it to be finished”).

1 Like

Thanks! I will take a look :slight_smile: