rtc_plugins/util/GIL.h

22 lines
431 B
C
Raw Normal View History

2025-04-15 21:54:54 +08:00
#include <Python.h>
2025-04-15 21:59:17 +08:00
#include <stdio.h>
#include <iostream>
2025-04-15 21:54:54 +08:00
struct PyLockGIL
{
PyLockGIL(): gstate(PyGILState_Ensure())
{
2025-04-15 21:59:17 +08:00
std::cout << "construct GIL" << std::endl;
2025-04-15 21:54:54 +08:00
}
~PyLockGIL()
{
PyGILState_Release(gstate);
2025-04-15 21:59:17 +08:00
std::cout << "destruct GIL" << std::endl;
2025-04-15 21:54:54 +08:00
}
PyLockGIL(const PyLockGIL&) = delete;
PyLockGIL& operator=(const PyLockGIL&) = delete;
PyGILState_STATE gstate;
};