pub trait TaskQueues<W: Worker>:
Sized
+ Send
+ Sync
+ 'static {
type WorkerQueues: WorkerQueues<W>;
// Required methods
fn new(token: Token) -> Self;
fn init_for_threads(
&self,
start_index: usize,
end_index: usize,
config: &Config,
);
fn update_for_threads(
&self,
start_index: usize,
end_index: usize,
config: &Config,
);
fn try_push_global(&self, task: Task<W>) -> Result<(), Task<W>>;
fn worker_queues(&self, thread_index: usize) -> Self::WorkerQueues;
fn close(&self, urgent: bool, token: Token);
fn drain(self) -> Vec<Task<W>>;
}Expand description
Trait that encapsulates the global and local task queues used by a Hive for managing tasks
within and between worker threads.
This trait is sealed - it cannot be implemented outside of this crate.
Required Associated Types§
type WorkerQueues: WorkerQueues<W>
Required Methods§
Sourcefn new(token: Token) -> Self
fn new(token: Token) -> Self
Returns a new instance.
The private Token is used to prevent this method from being called externally.
Sourcefn init_for_threads(
&self,
start_index: usize,
end_index: usize,
config: &Config,
)
fn init_for_threads( &self, start_index: usize, end_index: usize, config: &Config, )
Initializes the local queues for the given range of worker thread indices.
Sourcefn update_for_threads(
&self,
start_index: usize,
end_index: usize,
config: &Config,
)
fn update_for_threads( &self, start_index: usize, end_index: usize, config: &Config, )
Updates the queue settings from config for the given range of worker threads.
Sourcefn try_push_global(&self, task: Task<W>) -> Result<(), Task<W>>
fn try_push_global(&self, task: Task<W>) -> Result<(), Task<W>>
Tries to add a task to the global queue.
Returns an error with the task if the queue is disconnected.
Sourcefn worker_queues(&self, thread_index: usize) -> Self::WorkerQueues
fn worker_queues(&self, thread_index: usize) -> Self::WorkerQueues
Returns a WorkerQueues instance for the worker thread with the given index.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.