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