Struct session_types::ChanSelect
[−]
[src]
pub struct ChanSelect<'c, T> { // some fields omitted }
Heterogeneous selection structure for channels
This builds a structure of channels that we wish to select over. This is structured in a way such that the channels selected over cannot be interacted with (consumed) as long as the borrowing ChanSelect object exists. This is necessary to ensure memory safety.
The type parameter T is a return type, ie we store a value of some type T
that is returned in case its associated channels is selected on wait()
Methods
impl<'c, T> ChanSelect<'c, T>
[src]
fn new() -> ChanSelect<'c, T>
fn add_recv_ret<E, P, A: Send>(&mut self, chan: &'c Chan<E, Recv<A, P>>, ret: T)
Add a channel whose next step is Recv
Once a channel has been added it cannot be interacted with as long as it is borrowed here (by virtue of borrow checking and lifetimes).
fn add_offer_ret<E, P, Q>(&mut self, chan: &'c Chan<E, Offer<P, Q>>, ret: T)
fn wait(self) -> T
Find a Receiver (and hence a Chan) that is ready to receive.
This method consumes the ChanSelect, freeing up the borrowed Receivers to be consumed.
fn len(&self) -> usize
How many channels are there in the structure?
impl<'c> ChanSelect<'c, usize>
[src]
Default use of ChanSelect works with usize and returns the index
of the selected channel. This is also the implementation used by
the chan_select!
macro.