Mantid
Loading...
Searching...
No Matches
Framework
PythonInterface
core
src
ReleaseGlobalInterpreterLock.cpp
Go to the documentation of this file.
1
// Mantid Repository : https://github.com/mantidproject/mantid
2
//
3
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4
// NScD Oak Ridge National Laboratory, European Spallation Source,
5
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
#include "
MantidPythonInterface/core/ReleaseGlobalInterpreterLock.h
"
8
9
namespace
Mantid::PythonInterface
{
10
15
ReleaseGlobalInterpreterLock::ReleaseGlobalInterpreterLock
()
16
: m_tracefunc(nullptr), m_tracearg(nullptr), m_saved(nullptr) {
17
PyThreadState *curThreadState = PyThreadState_GET();
18
m_tracefunc
= curThreadState->c_tracefunc;
19
m_tracearg
= curThreadState->c_traceobj;
20
Py_XINCREF(
m_tracearg
);
21
PyEval_SetTrace(
nullptr
,
nullptr
);
22
m_saved
= PyEval_SaveThread();
23
}
24
28
ReleaseGlobalInterpreterLock::~ReleaseGlobalInterpreterLock
() {
29
PyEval_RestoreThread(
m_saved
);
30
PyEval_SetTrace(
m_tracefunc
,
m_tracearg
);
31
Py_XDECREF(
m_tracearg
);
32
}
33
34
}
// namespace Mantid::PythonInterface
ReleaseGlobalInterpreterLock.h
Mantid::PythonInterface::ReleaseGlobalInterpreterLock::~ReleaseGlobalInterpreterLock
~ReleaseGlobalInterpreterLock()
Destructor.
Definition:
ReleaseGlobalInterpreterLock.cpp:28
Mantid::PythonInterface::ReleaseGlobalInterpreterLock::m_saved
PyThreadState * m_saved
Definition:
ReleaseGlobalInterpreterLock.h:30
Mantid::PythonInterface::ReleaseGlobalInterpreterLock::m_tracefunc
Py_tracefunc m_tracefunc
Definition:
ReleaseGlobalInterpreterLock.h:28
Mantid::PythonInterface::ReleaseGlobalInterpreterLock::ReleaseGlobalInterpreterLock
ReleaseGlobalInterpreterLock()
Default constructor.
Definition:
ReleaseGlobalInterpreterLock.cpp:15
Mantid::PythonInterface::ReleaseGlobalInterpreterLock::m_tracearg
PyObject * m_tracearg
Definition:
ReleaseGlobalInterpreterLock.h:29
Mantid::PythonInterface
Definition:
CallMethod.h:17
Generated on Tue Jan 3 2023 11:57:58 for Mantid by
1.9.5