24#ifndef PXR_BASE_TF_PY_LOCK_H
25#define PXR_BASE_TF_PY_LOCK_H
29#ifdef PXR_PYTHON_SUPPORT_ENABLED
33#include "pxr/base/tf/api.h"
35PXR_NAMESPACE_OPEN_SCOPE
147 friend struct TfPyEnsureGILUnlockedObj;
148 enum _UnlockedTag { _ConstructUnlocked };
151 PyGILState_STATE _gilState;
152 PyThreadState *_savedState;
154 bool _allowingThreads:1;
158struct TfPyEnsureGILUnlockedObj
162 TF_API TfPyEnsureGILUnlockedObj();
190#define TF_PY_ALLOW_THREADS_IN_SCOPE() \
191 TfPyEnsureGILUnlockedObj __py_lock_allow_threads__
193PXR_NAMESPACE_CLOSE_SCOPE
198#define TF_PY_ALLOW_THREADS_IN_SCOPE()
Convenience class for accessing the Python Global Interpreter Lock.
TF_API ~TfPyLock()
Releases Python GIL and restores prior threads state.
TF_API void BeginAllowThreads()
Unlock the GIL temporarily to allow other threads to use python.
TF_API TfPyLock()
Acquires the Python GIL and swaps in callers thread state.
TF_API void EndAllowThreads()
End allowing other threads, reacquiring the lock state.
TF_API void Acquire()
(Re)acquires GIL and thread state, if previously released.
TF_API void Release()
Explicitly releases GIL and thread state.
Intended to replace a direct include of Python.h, which causes several build problems with certain co...