Trait stack_queue::BackgroundQueue
source · pub trait BackgroundQueue: Send + Sync + Sized + 'static {
type Task: Send + Sync + Sized + 'static;
// Required method
fn batch_process<const N: usize>(
tasks: UnboundedRange<'_, Self::Task, N>
) -> impl Future<Output = ()> + Send;
// Provided method
fn auto_batch<const N: usize>(task: Self::Task)
where Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>> { ... }
}
Expand description
Fire and forget auto-batched queue
§Example
struct EchoQueue;
#[local_queue]
impl BackgroundQueue for EchoQueue {
type Task = (usize, oneshot::Sender<usize>);
fn batch_process<const N: usize>(tasks: UnboundedRange<'_, Self::Task, N>) -> impl Future<Output = ()> + Send {
for (val, tx) in tasks.into_bounded().into_iter() {
tx.send(val).ok();
}
}
}
Required Associated Types§
Required Methods§
fn batch_process<const N: usize>( tasks: UnboundedRange<'_, Self::Task, N> ) -> impl Future<Output = ()> + Send
Provided Methods§
sourcefn auto_batch<const N: usize>(task: Self::Task)where
Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>,
fn auto_batch<const N: usize>(task: Self::Task)where
Self: LocalQueue<N, BufferCell = BufferCell<Self::Task>>,
Object Safety§
This trait is not object safe.