Skip to main content

BarrierHeldMainRef

Struct BarrierHeldMainRef 

Source
pub struct BarrierHeldMainRef(/* private fields */);
Expand description

Reference to VPP per-thread main library context with barrier held

This is a safe wrapper around vlib_main_t, providing access to its fields.

A &mut BarrierHeldMainRef is equivalent to a vlib_main_t * in C (a *mut vlib_main_t in Rust).

See also MainRef for a variant without the constraint that the caller holds the main thread barrier.

Implementations§

Source§

impl BarrierHeldMainRef

Source

pub unsafe fn from_ptr_mut<'a>(ptr: *mut vlib_main_t) -> &'a mut Self

Creates a &mut BarrierHeldMainRef directly from a pointer

§Safety
  • All the safety requirements of MainRef::from_ptr_mut apply.
  • Additionally, the caller must that no other thread is concurrently accessing VPP data structures. This is typically ensured by holding the main thread barrier, but also applies during initialisation before worker threads are started or shutdown after worker threads are stopped.

Methods from Deref<Target = MainRef>§

Source

pub unsafe fn get_buffers<'a, 'me, 'buf: 'me, FeatureData, const N: usize>( &'me self, from_indices: &'a [u32], to: &mut ArrayVec<&'buf mut BufferRef<FeatureData>, N>, )

Get pointers to buffers for the given buffer indices, writing them into the provided to arrayvec.

This is similar to vlib_get_buffers in the C API.

Note that although it would be more idiomatic to return an ArrayVec directly, this method takes a mutable reference to an ArrayVec to avoid an unnecessary copy when returning.

§Safety
  • The caller must ensure that to has enough capacity to hold all the buffers corresponding to the indices in from_indices.
  • Each index in from_indices must be valid and the caller must have ownership of the buffer it corresponds to.
  • Each buffer’s feature_arc_index and current_config_index must be consistent with the FeatureData type. If they are not known (i.e. because the caller the node isn’t being executed in a feature arc), FeatureData should be a zero-sized type such as ().
  • The capacity of from_indices must be a multiple of 8 (note though that the length is allowed not to be). In other words, it must be valid to read multiples of 8 from the underlying memory (possibly returning uninitialised or stale data) without faulting.
Source

pub unsafe fn buffer_enqueue_to_next<N: Node, V: VectorBufferIndex>( &self, node: &mut NodeRuntimeRef<N>, from: &[V], nexts: &[u16], )

Enqueues a slice of buffer indices to a next node

This corresponds to the VPP C function vlib_buffer_enqueue_to_next.

§Safety
  • The length of the from and next slices must match.
  • The next node must have a Vector type of u32 (or the C equivalent).
  • The next node must have a Scalar type of () (or the C equivalent).
  • The next node must have an Aux type of () (or the C equivalent).
  • vlib_buffer_func_main must have been filled in with valid function pointers (which will be done by VPP at initialisation time).
  • The buffer state, such as current_data and length must be set according to the preconditions of the next node.
  • Each entry in the from slice must be a valid index to a buffer.
  • Each entry in the nexts slice must be a valid next node index.
Source

pub fn as_ptr(&self) -> *mut vlib_main_t

Returns the raw pointer to the underlying vlib_main_t

Source

pub fn thread_index(&self) -> u16

Returns the 0-based thread index of this VPP main context

Trait Implementations§

Source§

impl Deref for BarrierHeldMainRef

Source§

type Target = MainRef

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

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>,

Source§

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.