devela::_dep::pyo3::sync

Trait OnceExt

pub trait OnceExt: Sealed {
    // 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(&OnceState),
    );
}
Available on crate features dep_pyo3 and std only.
Expand description

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

Required Methods§

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.

fn call_once_force_py_attached( &self, py: Python<'_>, f: impl FnOnce(&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.

Implementors§

§

impl OnceExt for Once