Hi, I’ve been trying to be able to embed Julia in a C++ application and access it from multiple (C++) threads (Why? Some context here).
After start learning how Julia “managed” threads work, I start trying to add methods to register an external thread as a Julia “unmanaged” one. However, at some point, I realized that the easiest way would be to have the main thread in Julia (a dedicated C++ thread where Julia has been initialized) accepting tasks and scheduling to other “managed” threads as needed. The tasks could be queued and waited for from any C++ thread since direct calls into the Julia runtime would be transferred to and run in the main thread.
Now the problem is that I have not being able to have the main Julia thread waiting for C++ tasks, using a C++ condition variable for instance, and at the same time having the Julia running its scheduler in that very same thread. I can either be waiting on the C++ condition or on the Julia scheduler, but not both.
I’ve been doing several experiments, and looked into using Libuv condition variables and streams, but without success.
I think I need a way to have Julia in its internal loop but while having a hook that can be triggered from the C++ side.
Does anyone have any hint or advice on I can solve this problem? Thanks.