OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::PythonRuntimeLease Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/plugin/PythonInterpreter.hpp>

Collaboration diagram for Slic3r::PythonRuntimeLease:

Public Member Functions

 PythonRuntimeLease ()=default
 PythonRuntimeLease (PythonRuntimeLease &&other) noexcept
PythonRuntimeLease & operator= (PythonRuntimeLease &&other) noexcept
 ~PythonRuntimeLease ()
 PythonRuntimeLease (const PythonRuntimeLease &)=delete
PythonRuntimeLease & operator= (const PythonRuntimeLease &)=delete
 operator bool () const

Private Member Functions

 PythonRuntimeLease (PythonInterpreter &interpreter)
void release ()

Private Attributes

PythonInterpreter * m_interpreter = nullptr
std::shared_lock< std::shared_timed_mutex > m_lock

Static Private Attributes

static PythonInterpreter * s_owner = nullptr
static unsigned int s_depth = 0

Friends

class PythonInterpreter

Detailed Description

Constructor & Destructor Documentation

◆ PythonRuntimeLease() [1/4]

Slic3r::PythonRuntimeLease::PythonRuntimeLease ( )
default

References PythonRuntimeLease().

Referenced by PythonRuntimeLease(), PythonRuntimeLease(), PythonRuntimeLease(), operator=(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PythonRuntimeLease() [2/4]

Slic3r::PythonRuntimeLease::PythonRuntimeLease ( PythonRuntimeLease && other)
noexcept
62 : m_interpreter(other.m_interpreter), m_lock(std::move(other.m_lock))
63{
64 other.m_interpreter = nullptr;
65}
std::shared_lock< std::shared_timed_mutex > m_lock
Definition PythonInterpreter.hpp:159
PythonInterpreter * m_interpreter
Definition PythonInterpreter.hpp:158

References PythonRuntimeLease(), m_interpreter, and m_lock.

Here is the call graph for this function:

◆ ~PythonRuntimeLease()

Slic3r::PythonRuntimeLease::~PythonRuntimeLease ( )
92{
93 release();
94}
void release()
Definition PythonInterpreter.cpp:78

References release().

Here is the call graph for this function:

◆ PythonRuntimeLease() [3/4]

Slic3r::PythonRuntimeLease::PythonRuntimeLease ( const PythonRuntimeLease & )
delete

References PythonRuntimeLease().

Here is the call graph for this function:

◆ PythonRuntimeLease() [4/4]

Slic3r::PythonRuntimeLease::PythonRuntimeLease ( PythonInterpreter & interpreter)
explicitprivate
43{
44 if (s_owner == &interpreter) {
45 m_interpreter = &interpreter;
46 ++s_depth;
47 return;
48 }
49
50 m_lock = std::shared_lock<std::shared_timed_mutex>(interpreter.m_runtime_mutex);
51 if (!interpreter.m_initialized.load(std::memory_order_acquire)) {
52 m_lock.unlock();
53 return;
54 }
55
56 m_interpreter = &interpreter;
57 s_owner = &interpreter;
58 s_depth = 1;
59}
static unsigned int s_depth
Definition PythonInterpreter.hpp:156
static PythonInterpreter * s_owner
Definition PythonInterpreter.hpp:155

References Slic3r::PythonInterpreter::m_initialized, m_interpreter, m_lock, Slic3r::PythonInterpreter::m_runtime_mutex, PythonInterpreter, s_depth, and s_owner.

Here is the call graph for this function:

Member Function Documentation

◆ operator bool()

Slic3r::PythonRuntimeLease::operator bool ( ) const
inlineexplicit
147{ return m_interpreter != nullptr; }

References m_interpreter.

◆ operator=() [1/2]

PythonRuntimeLease & Slic3r::PythonRuntimeLease::operator= ( const PythonRuntimeLease & )
delete

References PythonRuntimeLease().

Here is the call graph for this function:

◆ operator=() [2/2]

PythonRuntimeLease & Slic3r::PythonRuntimeLease::operator= ( PythonRuntimeLease && other)
noexcept
68{
69 if (this != &other) {
70 release();
71 m_lock = std::move(other.m_lock);
72 m_interpreter = other.m_interpreter;
73 other.m_interpreter = nullptr;
74 }
75 return *this;
76}

References PythonRuntimeLease(), m_interpreter, m_lock, and release().

Here is the call graph for this function:

◆ release()

void Slic3r::PythonRuntimeLease::release ( )
private
79{
80 if (!m_interpreter)
81 return;
82
83 if (s_owner == m_interpreter && s_depth > 0) {
84 --s_depth;
85 if (s_depth == 0)
86 s_owner = nullptr;
87 }
88 m_interpreter = nullptr;
89}

References m_interpreter, s_depth, and s_owner.

Referenced by ~PythonRuntimeLease(), and operator=().

Here is the caller graph for this function:

◆ PythonInterpreter

friend class PythonInterpreter
friend

References PythonInterpreter.

Referenced by PythonRuntimeLease(), and PythonInterpreter.

Member Data Documentation

◆ m_interpreter

PythonInterpreter* Slic3r::PythonRuntimeLease::m_interpreter = nullptr
private

◆ m_lock

std::shared_lock<std::shared_timed_mutex> Slic3r::PythonRuntimeLease::m_lock
private

◆ s_depth

unsigned int Slic3r::PythonRuntimeLease::s_depth = 0
thread_localstaticprivate

Referenced by PythonRuntimeLease(), and release().

◆ s_owner

PythonInterpreter * Slic3r::PythonRuntimeLease::s_owner = nullptr
thread_localstaticprivate

Referenced by PythonRuntimeLease(), and release().


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