MIRA
Public Member Functions | List of all members
ScopedGILThreadLock Class Reference

A scoped global interpreter (GIL) lock. More...

#include <python/ScopedGIL.h>

Public Member Functions

 ScopedGILThreadLock ()
 
 ~ScopedGILThreadLock ()
 
void unlock ()
 

Detailed Description

A scoped global interpreter (GIL) lock.

The GIL only allows one thread at a time to run in the python interpreter. Python normally releases the GIL at regular intervals, to give other threads a chance to run. If a C++ method is called from python (you are in C++), it is your job to release the GIL. If you go crunch numbers for 2 hours while holding the GIL, you will freeze the whole interpreter. You can release the GIL by creating an instance of ScopedGILThreadLock. It will automatically acquire the GIL back when it goes out of scope.

{
// ...do lengthy C++ stuff
} // GIL is acquire back

Constructor & Destructor Documentation

◆ ScopedGILThreadLock()

ScopedGILThreadLock ( )
inline

◆ ~ScopedGILThreadLock()

~ScopedGILThreadLock ( )
inline

Member Function Documentation

◆ unlock()

void unlock ( )
inline

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