Skip to content

Commit

Permalink
Expand comment for new interkeeper() function
Browse files Browse the repository at this point in the history
  • Loading branch information
lava committed Aug 27, 2020
1 parent b6f58a5 commit 70d508f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions matplotlibcpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ struct _interpreter {

/* For now, _interpreter is implemented as a singleton since its currently not possible to have
multiple independent embedded python interpreters without patching the python source code
or starting a separate process for each.
http://bytes.com/topic/python/answers/793370-multiple-independent-python-interpreters-c-c-program
or starting a separate process for each. [1]
Furthermore, many python objects expect that they are destructed in the same thread as they
were constructed. [2] So for advanced usage, a `kill()` function is provided so that library
users can manually ensure that the interpreter is constructed and destroyed within the
same thread.
1: http://bytes.com/topic/python/answers/793370-multiple-independent-python-interpreters-c-c-program
2: https://github.com/lava/matplotlib-cpp/pull/202#issue-436220256
*/

static _interpreter& get() {
Expand All @@ -115,6 +121,7 @@ struct _interpreter {
return interkeeper(true);
}

// Stores the actual singleton object referenced by `get()` and `kill()`.
static _interpreter& interkeeper(bool should_kill) {
static _interpreter ctx;
if (should_kill)
Expand Down

0 comments on commit 70d508f

Please sign in to comment.