Trait OnceExt

Source
pub trait OnceExt: Sealed {
    type OnceState;

    // Required methods
    fn call_once_py_attached(&self, py: Python<'_>, f: impl FnOnce());
    fn call_once_force_py_attached(
        &self,
        py: Python<'_>,
        f: impl FnOnce(&Self::OnceState),
    );
}
Expand description

Helper trait for Once to help avoid deadlocking when using a Once when attached to a Python thread.

Required Associated Types§

Source

type OnceState

The state of Once

Required Methods§

Source

fn call_once_py_attached(&self, py: Python<'_>, f: impl FnOnce())

Similar to call_once, but releases the Python GIL temporarily if blocking on another thread currently calling this Once.

Source

fn call_once_force_py_attached( &self, py: Python<'_>, f: impl FnOnce(&Self::OnceState), )

Similar to call_once_force, but releases the Python GIL temporarily if blocking on another thread currently calling this Once.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl OnceExt for Once

Source§

impl OnceExt for Once

Available on crate feature parking_lot only.
Source§

type OnceState = OnceState

Source§

fn call_once_py_attached(&self, _py: Python<'_>, f: impl FnOnce())

Source§

fn call_once_force_py_attached( &self, _py: Python<'_>, f: impl FnOnce(&OnceState), )

Implementors§

⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here