Embedding: thread safety requirements


#1

The embedding section of the manual is silent on this topic, but I’m under the impression that the embedding API is not thread-safe. I want to be able to invoke an instance of the Julia runtime from different threads in an embedding application. I was initially speculating that I would need to perform all invocations of the Julia API from the same thread that initialized the runtime. That would be somewhat complicated, but doable. However, it occurred to me that it might be sufficient just to guard the API calls with a mutex. Or maybe I don’t need to worry about it at all (but I doubt it).

Can someone knowledgeable enlighten me?


#2

See: https://docs.julialang.org/en/latest/manual/calling-c-and-fortran-code.html#Thread-safety-1


#3

I thought the callback situation would be analogous to the embedding situation, but wanted to make sure I wasn’t making things needlessly more complicated.

Thanks for the reply.


#4

@stevengj That link is currently broken. I wonder if thread-safety addressed in the latest docs re: embedding Julia in C?