Trait timely::communication::Allocate
source · pub trait Allocate {
// Required methods
fn index(&self) -> usize;
fn peers(&self) -> usize;
fn allocate<T>(
&mut self,
identifier: usize,
) -> (Vec<Box<dyn Push<T>>>, Box<dyn Pull<T>>)
where T: Exchangeable;
fn events(&self) -> &Rc<RefCell<Vec<usize>>>;
// Provided methods
fn await_events(&self, _duration: Option<Duration>) { ... }
fn receive(&mut self) { ... }
fn release(&mut self) { ... }
fn pipeline<T>(
&mut self,
identifier: usize,
) -> (Pusher<T, Pusher<T>>, Puller<T, Puller<T>>)
where T: 'static { ... }
}
Expand description
A type capable of allocating channels.
There is some feature creep, in that this contains several convenience methods about the nature of the allocated channels, and maintenance methods to ensure that they move records around.
Required Methods§
sourcefn allocate<T>(
&mut self,
identifier: usize,
) -> (Vec<Box<dyn Push<T>>>, Box<dyn Pull<T>>)where
T: Exchangeable,
fn allocate<T>(
&mut self,
identifier: usize,
) -> (Vec<Box<dyn Push<T>>>, Box<dyn Pull<T>>)where
T: Exchangeable,
Constructs several send endpoints and one receive endpoint.
sourcefn events(&self) -> &Rc<RefCell<Vec<usize>>>
fn events(&self) -> &Rc<RefCell<Vec<usize>>>
A shared queue of communication events with channel identifier.
It is expected that users of the channel allocator will regularly drain these events in order to drive their computation. If they fail to do so the event queue may become quite large, and turn into a performance problem.
Provided Methods§
sourcefn await_events(&self, _duration: Option<Duration>)
fn await_events(&self, _duration: Option<Duration>)
Awaits communication events.
This method may park the current thread, for at most duration
,
until new events arrive.
The method is not guaranteed to wait for any amount of time, but
good implementations should use this as a hint to park the thread.
sourcefn receive(&mut self)
fn receive(&mut self)
Ensure that received messages are surfaced in each channel.
This method should be called to ensure that received messages are surfaced in each channel, but failing to call the method does not ensure that they are not surfaced.
Generally, this method is the indication that the allocator should present messages contained in otherwise scarce resources (for example network buffers), under the premise that someone is about to consume the messages and release the resources.
sourcefn release(&mut self)
fn release(&mut self)
Signal the completion of a batch of reads from channels.
Conventionally, this method signals to the communication fabric that the worker is taking a break from reading from channels, and the fabric should consider re-acquiring scarce resources. This can lead to the fabric performing defensive copies out of un-consumed buffers, and can be a performance problem if invoked casually.