Skip to content

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

Open
@eschnett

Description

@eschnett

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions