Skip to main content

Fanout

Struct Fanout 

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

A set of consumers that all receive the same sample.

liblsl calls this the send buffer (src/send_buffer.h). Each consumer holds its own queue, so a slow consumer loses only its own samples. SPEC.md 8.8.

The fanout also holds the history of the resume feature, and the timestamp deducer that gives the history its full timestamps. docs/extensions.md, section resume.

Implementations§

Source§

impl Fanout

Source

pub fn new() -> Self

Build an empty set for a stream with an irregular rate and the default history limits.

Source

pub fn with_rate(srate: f64, limits: HistoryLimits) -> Self

Build an empty set for a stream with the nominal rate srate.

The rate gives the deduced timestamps and the time limit of the history.

Source

pub fn push_metadata( &self, key: String, value: String, timestamp: f64, ) -> MetadataUpdate

Record a live metadata change at the current sample sequence boundary and wake all active consumers (docs/roadmap.md, step 16).

Source

pub fn metadata_generation(&self) -> u64

Current metadata generation counter (0 when no metadata was pushed).

Source

pub fn metadata_snapshot(&self) -> (u64, BTreeMap<String, MetadataUpdate>)

Snapshot the current latest metadata map together with its generation.

Source

pub fn read_metadata_since( &self, cursor: &mut u64, out: &mut Vec<MetadataUpdate>, )

Append any live metadata updates emitted after *cursor into out and advance *cursor. Fast-paths with a single atomic load when idle.

Source

pub fn start_history(&self) -> bool

Start the history, if the limits allow it. The result is true when the history is on.

The history holds each sample that the outlet pushes from this point. A second call changes nothing. docs/extensions.md, history rule 3.

Source

pub fn history_len(&self) -> usize

How many samples the history holds across RAM and disk. Zero when it is off.

Source

pub fn history_ram_bytes(&self) -> usize

Bytes currently held by the history in RAM. Zero when it is off.

Source

pub fn history_disk_bytes(&self) -> u64

Bytes currently held by the history in disk spool segments. Zero when off.

Source

pub fn history_spool_dir(&self) -> Option<PathBuf>

Path of the active disk spool directory, if disk spilling has started.

Source

pub fn read_history( &self, from: u64, until: u64, max: usize, out: &mut Vec<Sample>, ) -> Option<(u64, usize)>

Copy at most max samples of the history to the end of out, from the number from, and below the number until. Each sample has its full timestamp.

The call takes the lock of the set one time. A push thus waits for at most the copy of max samples (and never for disk I/O). History::read gives the rules and the result.

Source

pub fn read_history_packed( &self, from: u64, until: u64, max: usize, out: &mut Vec<PackedSample>, ) -> Option<(u64, usize)>

Share at most max packed samples of the history to the end of out.

RAM reads clone Arc handles under the lock; disk reads execute outside the Fanout lock so live pushes and other consumers never wait on disk I/O.

Source

pub fn add(&self, capacity: usize) -> Arc<SampleQueue> ⓘ

Add a consumer with its own queue.

Source

pub fn add_resumable(&self, capacity: usize) -> (Arc<SampleQueue>, u64)

Add a consumer for the resume feature. The result is its queue and N, the number of the first sample that the queue gets.

The queue gives the full timestamp of each sample (SampleQueue::pop_many_full). The history holds the samples below N. docs/extensions.md, resend rule 1.

Source

pub fn next_number(&self) -> u64

The number that the next pushed sample gets.

Source

pub fn remove(&self, q: &Arc<SampleQueue>)

Remove a consumer.

Source

pub fn count(&self) -> usize

How many consumers are connected.

Source

pub fn health(&self) -> OutletHealth

Snapshot the fill and drop state of every connected consumer queue.

Source

pub fn push(&self, s: &Sample)

Give one sample to every consumer.

A consumer that has gone away is dropped from the set. The call never waits, whatever any consumer is doing.

Source

pub fn push_packed(&self, s: PackedSample)

Give one PackedSample to every consumer and the resume history, sharing its Arc payload with zero byte copies.

Source

pub fn push_many(&self, samples: &[Sample])

Give several samples to every consumer, with one lock for the set.

The result for each consumer is the same as one Fanout::push for each sample, in order.

Source

pub fn push_many_packed(&self, samples: &[PackedSample])

Give several PackedSamples to every consumer and the resume history with one lock, sharing each Arc payload with zero byte copies.

Source

pub fn close(&self)

Close every consumer queue and shared-memory ring.

Trait Implementations§

Source§

impl Debug for Fanout

Source§

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

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

impl Default for Fanout

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !Freeze for Fanout

§

impl Forget for Fanout

§

impl Move for Fanout

§

impl RefUnwindSafe for Fanout

§

impl Send for Fanout

§

impl Sync for Fanout

§

impl Unpin for Fanout

§

impl UnsafeUnpin for Fanout

§

impl UnwindSafe for Fanout

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.