class PythonGILLock

Overview

Manages the Pyton GIL. Useful for threads. More…

#include <python_interpreter_state.h>

class PythonGILLock {
public:
    // construction

    PythonGILLock(PyGILState_STATE& state, const bool acquire = true);
    PythonGILLock(const PythonGILLock&);

    // methods

    PythonGILLock& operator = (const PythonGILLock&);
    void acquire();
    void release();
    static bool hasGIL();
};

Detailed Documentation

Manages the Pyton GIL. Useful for threads.

Construction

PythonGILLock(PyGILState_STATE& state, const bool acquire = true)

Constructor. Acquires GIL if requested.

Parameters:

state

GIL State

acquire

Should GIL be acquired

Methods

void acquire()

Acquire GIL.

void release()

Release GIL.

static bool hasGIL()

Does this thread have the GIL?