pub(crate) enum GILGuard {
Assumed,
Ensured {
gstate: PyGILState_STATE,
},
}
Expand description
RAII type that represents the Global Interpreter Lock acquisition.
Variants§
Assumed
Indicates the GIL was already held with this GILGuard was acquired.
Ensured
Indicates that we actually acquired the GIL when this GILGuard was acquired
Fields
§
gstate: PyGILState_STATE
Implementations§
Source§impl GILGuard
impl GILGuard
Sourcepub(crate) fn acquire() -> Self
pub(crate) fn acquire() -> Self
PyO3 internal API for acquiring the GIL. The public API is Python::with_gil.
If the GIL was already acquired via PyO3, this returns
GILGuard::Assumed
. Otherwise, the GIL will be acquired and
GILGuard::Ensured
will be returned.
Sourcepub(crate) unsafe fn acquire_unchecked() -> Self
pub(crate) unsafe fn acquire_unchecked() -> Self
Acquires the GILGuard
without performing any state checking.
This can be called in “unsafe” contexts where the normal interpreter state
checking performed by GILGuard::acquire
may fail. This includes calling
as part of multi-phase interpreter initialization.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GILGuard
impl RefUnwindSafe for GILGuard
impl Send for GILGuard
impl Sync for GILGuard
impl Unpin for GILGuard
impl UnwindSafe for GILGuard
Blanket Implementations§
Source§impl<T> AssertNotZeroSized for T
impl<T> AssertNotZeroSized for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more