PythonQt
Public Member Functions | List of all members
PythonQtThreadStateSaver Class Reference

#include <PythonQtThreadSupport.h>

Public Member Functions

 PythonQtThreadStateSaver ()
 
 ~PythonQtThreadStateSaver ()
 
void save ()
 
void restore ()
 

Detailed Description

This class wraps the Python save/restore thread state API. It can be used to allow other Python threads to run when entering C++ code from Python code.

Definition at line 104 of file PythonQtThreadSupport.h.

Constructor & Destructor Documentation

◆ PythonQtThreadStateSaver()

PythonQtThreadStateSaver::PythonQtThreadStateSaver ( )
inline

Definition at line 108 of file PythonQtThreadSupport.h.

108  {
109  save();
110  }

References save().

◆ ~PythonQtThreadStateSaver()

PythonQtThreadStateSaver::~PythonQtThreadStateSaver ( )
inline

Definition at line 112 of file PythonQtThreadSupport.h.

112  {
113  restore();
114  }

References restore().

Member Function Documentation

◆ restore()

void PythonQtThreadStateSaver::restore ( )
inline

Definition at line 120 of file PythonQtThreadSupport.h.

120  {
121  if (_state) {
122  PyEval_RestoreThread(_state);
123  _state = nullptr;
124  }
125  }

Referenced by ~PythonQtThreadStateSaver().

◆ save()

void PythonQtThreadStateSaver::save ( )
inline

Definition at line 116 of file PythonQtThreadSupport.h.

116  {
117  _state = PyEval_SaveThread();
118  }

Referenced by PythonQtThreadStateSaver().


The documentation for this class was generated from the following file: