Trait RcuContext

Source
pub unsafe trait RcuContext {
    type Flavor: RcuFlavor;
    type Poller<'a>: RcuPoller + 'a
       where Self: 'a;

    // Required methods
    fn rcu_synchronize(&mut self);
    fn rcu_synchronize_poller(&self) -> Self::Poller<'_>;
}
Expand description

This trait defines the per-thread RCU context.

§Design

This trait exploits the borrowing rule of Rust.

At any given time, you can have either one mutable reference (&mut T) or any number of immutable references (&T).

By exploiting this rule, we can enforce that a thread never executes a RCU synchronization barrier at the same time as it holds a RCU read lock. For example, RcuReadContext::rcu_read_lock requires (&self), meaning we can nest as many read locks as we want. On the other hand, RcuContext::rcu_synchronize requires &mut self, meaning we can never call it while a read guard borrows &self.

§Safety

You must enforce single context per thread for a specific RCU flavor. Failure to do so can lead to a deadlock if a thread acquires a RCU read lock from one context and tries to do a RCU syncronization from another context.

Required Associated Types§

Source

type Flavor: RcuFlavor

Defines an API for unchecked RCU primitives.

Source

type Poller<'a>: RcuPoller + 'a where Self: 'a

Defines a grace period poller;

Required Methods§

Source

fn rcu_synchronize(&mut self)

Waits until the RCU grace period is over.

§Note

It cannot be called in a RCU critical section.

Source

fn rcu_synchronize_poller(&self) -> Self::Poller<'_>

Creates a RCU grace period poller.

§Note

It may be called in a RCU critical section.

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§

Source§

impl<const READ: bool, const DEFER: bool> RcuContext for RcuContextBp<READ, DEFER>

§Safety

There can only be 1 instance per thread.

Source§

impl<const READ: bool, const DEFER: bool> RcuContext for RcuContextMb<READ, DEFER>

§Safety

There can only be 1 instance per thread.

Source§

impl<const READ: bool, const DEFER: bool> RcuContext for RcuContextMemb<READ, DEFER>

§Safety

There can only be 1 instance per thread.

Source§

impl<const READ: bool, const DEFER: bool> RcuContext for RcuContextQsbr<READ, DEFER>

§Safety

There can only be 1 instance per thread.