rtc_plugins/util/GIL.h

22 lines
431 B
C++

#include <Python.h>
#include <stdio.h>
#include <iostream>
struct PyLockGIL
{
PyLockGIL(): gstate(PyGILState_Ensure())
{
std::cout << "construct GIL" << std::endl;
}
~PyLockGIL()
{
PyGILState_Release(gstate);
std::cout << "destruct GIL" << std::endl;
}
PyLockGIL(const PyLockGIL&) = delete;
PyLockGIL& operator=(const PyLockGIL&) = delete;
PyGILState_STATE gstate;
};