Skip to main content

Pool

Struct Pool 

Source
pub struct Pool { /* private fields */ }
Expand description

A pool of samples in shared memory, made by a writer for the samples it loans (zero-copy): fixed-size slots that the writer fills and the readers of this host map and read in place. A slot is reused once no one holds a reference to it: the writer, while the sample is in its history, and each reader, while it has the sample.

Each slot has a generation, changed each time the writer takes it, so that a reference to an older sample of the slot is not taken for the new one.

Implementations§

Source§

impl Pool

Source

pub fn create(dir: &Path, slots: u32, slot_size: usize) -> Result<Arc<Pool>>

Makes a pool of slots slots for payloads of up to slot_size octets (rounded up, see Self::slot_size) in dir.

Source

pub fn open(dir: &Path, id: u64) -> Result<Arc<Pool>>

Maps the pool id of dir, made by a writer of this host.

Source

pub fn id(&self) -> u64

Its id, which references name it by.

Source

pub fn slot_size(&self) -> usize

The largest payload a slot holds.

Source

pub fn slots(&self) -> u32

The number of slots.

Source

pub fn acquire(self: &Arc<Self>) -> Option<PoolSlot>

Takes a free slot for the writer; None if every slot is held. It holds zeros the first time, then the sample it held last.

Source

pub fn held(&self) -> usize

How many slots are held.

Trait Implementations§

Source§

impl Debug for Pool

Source§

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

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

impl Drop for Pool

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for Pool

Source§

impl Sync for Pool

Auto Trait Implementations§

§

impl Forget for Pool

§

impl Freeze for Pool

§

impl Move for Pool

§

impl RefUnwindSafe for Pool

§

impl Unpin for Pool

§

impl UnsafeUnpin for Pool

§

impl UnwindSafe for Pool

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.