Struct sample::signal::Fork [−][src]
pub struct Fork<S, D> { /* fields omitted */ }
Represents a forked Signal
that has not yet been split into its two branches.
A Fork
can be split into its two branches via either of the following methods:
fork.by_rc()
: consumes self and shares the fork viaRc<RefCell>
.fork.by_ref()
: borrows self and shares the fork via&RefCell
.
Methods
impl<S, D> Fork<S, D>
[src]
impl<S, D> Fork<S, D>
pub fn by_rc(self) -> (BranchRcA<S, D>, BranchRcB<S, D>)
[src]
pub fn by_rc(self) -> (BranchRcA<S, D>, BranchRcB<S, D>)
Consumes the Fork
and returns two branches that share the signal and inner ring buffer
via a reference countered pointer (Rc
).
Note: This requires dynamical allocation as Rc<RefCell<Self>>
is used to share the signal
and ring buffer. A user may avoid this dynamic allocation by using the Fork::by_ref
method instead, however this comes with the ergonomic cost of bounding the lifetime of the
branches to the lifetime of the fork.
Fork::by_ref
pub fn by_ref(&mut self) -> (BranchRefA<S, D>, BranchRefB<S, D>)
[src]
pub fn by_ref(&mut self) -> (BranchRefA<S, D>, BranchRefB<S, D>)
Mutably borrows the Fork
and returns two branches that share the signal and inner ring
buffer via reference.
This is more efficient than Fork::by_rc
as it does not require Rc
, however it may be
less ergonomic in some cases as the returned branches are bound to the lifetime of Fork
.