Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Use a manager thread to support full C++ multi-threading #62

Open
eschnett opened this issue Jan 17, 2024 · 0 comments
Open

Idea: Use a manager thread to support full C++ multi-threading #62

eschnett opened this issue Jan 17, 2024 · 0 comments

Comments

@eschnett
Copy link

I am calling Julia from C++ in kotekan, independent of jluna. (I was not aware of jluna when I implemented this.) kotekan is multi-threaded.

To support multi-threading, kotekan is using the following approach:

  • To initialize Julia, a new C++ thread ("Julia manager thread") is created
  • There is a global variable containing a task queue
  • The Julia manager thread waits for tasks in the queue and executes them
  • When a thread wants to call Julia, this call is placed onto the queue

A "task" is a std::function<void(void)> wrapping a closure. A std::future is used to return the value from Julia to the calling thread.

See https://github.com/kotekan/kotekan/blob/1b930517ab9fbc71cbc02a787af197a316627a09/lib/core/juliaManager.hpp and https://github.com/kotekan/kotekan/blob/1b930517ab9fbc71cbc02a787af197a316627a09/lib/core/juliaManager.cpp for the implementation in kotekan. A similar implementation would be possible for jluna.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant