Trait timely::communication::allocator::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§

source

fn index(&self) -> usize

The index of the worker out of (0..self.peers()).

source

fn peers(&self) -> usize

The number of workers in the communication group.

source

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.

source

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§

source

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.

source

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.

source

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.

source

fn pipeline<T>( &mut self, identifier: usize, ) -> (Pusher<T, Pusher<T>>, Puller<T, Puller<T>>)
where T: 'static,

Constructs a pipeline channel from the worker to itself.

By default, this method uses the thread-local channel constructor based on a shared VecDeque which updates the event queue.

Object Safety§

This trait is not object safe.

Implementors§