Struct linux_futex::PiFutex

source ·
#[repr(transparent)]
pub struct PiFutex<Scope> { pub value: AtomicU32, /* private fields */ }
Expand description

A Linux-specific priority inheriting fast user-space locking primitive.

Unlike with a regular Futex, the value of a PiFutex has meaning to the Linux kernel, taking away some flexibility. User-space must follow the assumed protocol to allow the kernel to properly implement priority inheritance.

See the Priority-inheritance futexes section of the Linux futex man page for details.

PiFutex<Private> may only be used from the same address space (the same process) and is faster than a PiFutex<Shared>, which may be used accross address spaces (processes).

Fields§

§value: AtomicU32

Implementations§

source§

impl<S> PiFutex<S>

source

pub const fn new(value: u32) -> Self

Create a new PiFutex with an initial value.

source

pub const WAITERS: u32 = 2_147_483_648u32

The FUTEX_WAITERS bit that indicates there are threads waiting.

source

pub const OWNER_DIED: u32 = 1_073_741_824u32

The FUTEX_OWNER_DIED bit that indicates the owning thread died.

source

pub const TID_MASK: u32 = 1_073_741_823u32

The bits that are used for storing the thread id (FUTEX_TID_MASK).

source§

impl<S: Scope> PiFutex<S>

source

pub fn lock_pi(&self) -> Result<(), TryAgainError>

See FUTEX_LOCK_PI in the Linux futex man page.

source

pub fn lock_pi_until(&self, timeout: impl Timeout) -> Result<(), TimedLockError>

See FUTEX_LOCK_PI in the Linux futex man page.

source

pub fn trylock_pi(&self) -> Result<(), TryAgainError>

See FUTEX_TRYLOCK_PI in the Linux futex man page.

source

pub fn unlock_pi(&self)

See FUTEX_UNLOCK_PI in the Linux futex man page.

Trait Implementations§

source§

impl<S> Debug for PiFutex<S>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S> Default for PiFutex<S>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Scope> !Freeze for PiFutex<Scope>

§

impl<Scope> RefUnwindSafe for PiFutex<Scope>
where Scope: RefUnwindSafe,

§

impl<Scope> Send for PiFutex<Scope>
where Scope: Send,

§

impl<Scope> Sync for PiFutex<Scope>
where Scope: Sync,

§

impl<Scope> Unpin for PiFutex<Scope>
where Scope: Unpin,

§

impl<Scope> UnwindSafe for PiFutex<Scope>
where Scope: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.