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
impl Fanout
Sourcepub fn new() -> Self
pub fn new() -> Self
Build an empty set for a stream with an irregular rate and the default history limits.
Sourcepub fn with_rate(srate: f64, limits: HistoryLimits) -> Self
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.
Sourcepub fn push_metadata(
&self,
key: String,
value: String,
timestamp: f64,
) -> MetadataUpdate
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).
Sourcepub fn metadata_generation(&self) -> u64
pub fn metadata_generation(&self) -> u64
Current metadata generation counter (0 when no metadata was pushed).
Sourcepub fn metadata_snapshot(&self) -> (u64, BTreeMap<String, MetadataUpdate>)
pub fn metadata_snapshot(&self) -> (u64, BTreeMap<String, MetadataUpdate>)
Snapshot the current latest metadata map together with its generation.
Sourcepub fn read_metadata_since(
&self,
cursor: &mut u64,
out: &mut Vec<MetadataUpdate>,
)
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.
Sourcepub fn start_history(&self) -> bool
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.
Sourcepub fn history_len(&self) -> usize
pub fn history_len(&self) -> usize
How many samples the history holds across RAM and disk. Zero when it is off.
Sourcepub fn history_ram_bytes(&self) -> usize
pub fn history_ram_bytes(&self) -> usize
Bytes currently held by the history in RAM. Zero when it is off.
Sourcepub fn history_disk_bytes(&self) -> u64
pub fn history_disk_bytes(&self) -> u64
Bytes currently held by the history in disk spool segments. Zero when off.
Sourcepub fn history_spool_dir(&self) -> Option<PathBuf>
pub fn history_spool_dir(&self) -> Option<PathBuf>
Path of the active disk spool directory, if disk spilling has started.
Sourcepub fn read_history(
&self,
from: u64,
until: u64,
max: usize,
out: &mut Vec<Sample>,
) -> Option<(u64, usize)>
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.
Sourcepub fn read_history_packed(
&self,
from: u64,
until: u64,
max: usize,
out: &mut Vec<PackedSample>,
) -> Option<(u64, usize)>
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.
Sourcepub fn add(&self, capacity: usize) -> Arc<SampleQueue> ⓘ
pub fn add(&self, capacity: usize) -> Arc<SampleQueue> ⓘ
Add a consumer with its own queue.
Sourcepub fn add_resumable(&self, capacity: usize) -> (Arc<SampleQueue>, u64)
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.
Sourcepub fn next_number(&self) -> u64
pub fn next_number(&self) -> u64
The number that the next pushed sample gets.
Sourcepub fn remove(&self, q: &Arc<SampleQueue>)
pub fn remove(&self, q: &Arc<SampleQueue>)
Remove a consumer.
Sourcepub fn health(&self) -> OutletHealth
pub fn health(&self) -> OutletHealth
Snapshot the fill and drop state of every connected consumer queue.
Sourcepub fn push(&self, s: &Sample)
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.
Sourcepub fn push_packed(&self, s: PackedSample)
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.
Sourcepub fn push_many(&self, samples: &[Sample])
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.
Sourcepub fn push_many_packed(&self, samples: &[PackedSample])
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.