Trait TaskQueue

Source
pub trait TaskQueue:
    Send
    + Sync
    + Sized
    + 'static {
    type Task: Send + Sync + Sized + 'static;
    type Value: Send;

    // Required method
    fn batch_process<const N: usize>(
        assignment: PendingAssignment<'_, Self, N>,
    ) -> impl Future<Output = CompletionReceipt<Self>> + Send;

    // Provided method
    fn auto_batch<const N: usize>(task: Self::Task) -> BatchedTask<Self, N> 
       where Self: LocalQueue<N, BufferCell = TaskRef<Self>> { ... }
}
Expand description

Auto-batched queue whereby each task resolves to a value

§Example

struct EchoQueue;

#[local_queue(buffer_size = 64)]
impl TaskQueue for EchoQueue {
  type Task = usize;
  type Value = usize;

  async fn batch_process<const N: usize>(
    batch: PendingAssignment<'_, Self, N>,
  ) -> CompletionReceipt<Self> {
    batch.into_assignment().map(|val| val)
  }
}

Required Associated Types§

Source

type Task: Send + Sync + Sized + 'static

Source

type Value: Send

Required Methods§

Source

fn batch_process<const N: usize>( assignment: PendingAssignment<'_, Self, N>, ) -> impl Future<Output = CompletionReceipt<Self>> + Send

Provided Methods§

Source

fn auto_batch<const N: usize>(task: Self::Task) -> BatchedTask<Self, N>
where Self: LocalQueue<N, BufferCell = TaskRef<Self>>,

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.

Implementors§