Trait timely::communication::Allocate[][src]

pub trait Allocate {
    pub fn index(&self) -> usize;
pub fn peers(&self) -> usize;
pub fn allocate<T>(
        &mut self,
        identifier: usize
    ) -> (Vec<Box<dyn Push<Message<T>> + 'static, Global>, Global>, Box<dyn Pull<Message<T>> + 'static, Global>)
    where
        T: Data
;
pub fn events(&self) -> &Rc<RefCell<VecDeque<(usize, Event)>>>; pub fn await_events(&self, _duration: Option<Duration>) { ... }
pub fn receive(&mut self) { ... }
pub fn release(&mut self) { ... }
pub fn pipeline<T>(
        &mut self,
        identifier: usize
    ) -> (Pusher<Message<T>, Pusher<Message<T>>>, Puller<Message<T>, Puller<Message<T>>>)
    where
        T: 'static
, { ... } }

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

pub fn index(&self) -> usize[src]

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

pub fn peers(&self) -> usize[src]

The number of workers in the communication group.

pub fn allocate<T>(
    &mut self,
    identifier: usize
) -> (Vec<Box<dyn Push<Message<T>> + 'static, Global>, Global>, Box<dyn Pull<Message<T>> + 'static, Global>) where
    T: Data
[src]

Constructs several send endpoints and one receive endpoint.

pub fn events(&self) -> &Rc<RefCell<VecDeque<(usize, Event)>>>[src]

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.

Loading content...

Provided methods

pub fn await_events(&self, _duration: Option<Duration>)[src]

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.

pub fn receive(&mut self)[src]

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.

pub fn release(&mut self)[src]

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.

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

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.

Loading content...

Implementors

impl Allocate for Generic[src]

impl Allocate for Process[src]

impl Allocate for Thread[src]

impl Allocate for ProcessAllocator[src]

impl<A> Allocate for TcpAllocator<A> where
    A: Allocate
[src]

Loading content...