pub struct AsyncProcessor { /* private fields */ }
Expand description
A processor that can execute async tasks with a limit on the number of tasks that can be executed concurrently.
Implementations§
source§impl AsyncProcessor
impl AsyncProcessor
sourcepub fn new(
metric_name: &str,
number_of_threads: usize,
number_of_pending_tasks: usize,
) -> Result<Self>
pub fn new( metric_name: &str, number_of_threads: usize, number_of_pending_tasks: usize, ) -> Result<Self>
Create a new AsyncProcessor
with the given number of threads and the number of pending
tasks.
sourcepub fn reserve(&self) -> Result<AsyncReservation, OutOfCapacity>
pub fn reserve(&self) -> Result<AsyncReservation, OutOfCapacity>
Reserve a slot for a task to be executed.
sourcepub fn spawn_reserved<F>(
&self,
reservation: AsyncReservation,
future: F,
) -> JoinHandle<F::Output>
pub fn spawn_reserved<F>( &self, reservation: AsyncReservation, future: F, ) -> JoinHandle<F::Output>
Spawn a task with a reservation.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AsyncProcessor
impl !RefUnwindSafe for AsyncProcessor
impl Send for AsyncProcessor
impl Sync for AsyncProcessor
impl Unpin for AsyncProcessor
impl !UnwindSafe for AsyncProcessor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more