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>>,
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.