29 #ifndef TOMOGRAPHER_PY_PYGIL_H 30 #define TOMOGRAPHER_PY_PYGIL_H 35 #include <tomographerpy/common.h> 40 #include <tomographerpy/pylogger.h> 43 #define TPY_EXPR_WITH_GIL( x ) \ 44 [&]() { py::gil_scoped_acquire _tpy_gil; return (x); } () 50 class GilProtectedPyLogger;
118 require_gil_acquisition(require_gil_acquisition_)
131 require_gil_acquisition =
value;
137 if (require_gil_acquisition) {
138 py::gil_scoped_acquire gil_acquire;
139 logger.emitLog(level, origin, msg);
141 logger.emitLog(level, origin, msg);
147 bool require_gil_acquisition;
Base namespace for the Tomographer project.
Logger providing transparent integration with Python's logging module.
void emitLog(int level, const char *origin, const std::string &msg)
The callback function for the logger, you shouldn't call this directly.
PyLogger & getLogger() const
The PyLogger which we relay messages to.
void requireGilAcquisition(bool value)
Instruct to acquire (true) or not (false) the GIL when emitting messages.
Some C++ utilities, with a tad of C++11 tricks.
GilProtectedPyLogger(PyLogger &logger_, bool require_gil_acquisition_=true)
Constructor.
Default traits for Logger implementations.
Traits template struct to be specialized for specific Logger implementations.
VarValueDecoder< T >::RetType value(const Var &var)
Access the value of the given variable, as a C++ type.
bool getRequireGilAcquisition() const
Whether or not we are set to acquire the GIL for emitting messages at this point. ...
C++ Classes and Utilities for Python Modules.
Logger type that relays to (wraps around) a PyLogger while protecting the call with GIL acquisition...
#define tomographer_assert(...)
Assertion test macro.
Utilities for logging messages.