pub struct CriticalSection<'cs> { /* private fields */ }
Expand description

Critical section token.

An instance of this type indicates that the current thread is executing code within a critical section.

Implementations

Creates a critical section token.

This method is meant to be used to create safe abstractions rather than being directly used in applications.

Safety

This must only be called when the current thread is in a critical section. The caller must ensure that the returned instance will not live beyond the end of the critical section.

The caller must use adequate fences to prevent the compiler from moving the instructions inside the critical section to the outside of it. Sequentially consistent fences are suggested immediately after entry and immediately before exit from the critical section.

Note that the lifetime 'cs of the returned instance is unconstrained. User code must not be able to influence the lifetime picked for this type, since that might cause it to be inferred to 'static.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.