Struct bounded_executor::BoundedExecutor
source · pub struct BoundedExecutor { /* private fields */ }
Implementations§
source§impl BoundedExecutor
impl BoundedExecutor
sourcepub fn new(capacity: usize, executor: Handle) -> Self
pub fn new(capacity: usize, executor: Handle) -> Self
Create a new BoundedExecutor
from an existing tokio [Handle
]
with a maximum concurrent task capacity of capacity
.
sourcepub async fn spawn<F>(&self, f: F) -> JoinHandle<F::Output>where
F: Future + Send + 'static,
F::Output: Send + 'static,
pub async fn spawn<F>(&self, f: F) -> JoinHandle<F::Output>where F: Future + Send + 'static, F::Output: Send + 'static,
sourcepub fn try_spawn<F>(&self, f: F) -> Result<JoinHandle<F::Output>, F>where
F: Future + Send + 'static,
F::Output: Send + 'static,
pub fn try_spawn<F>(&self, f: F) -> Result<JoinHandle<F::Output>, F>where F: Future + Send + 'static, F::Output: Send + 'static,
Try to spawn a Future
on the BoundedExecutor
. If the BoundedExecutor
is at capacity, this will return an Err(F)
, passing back the future the
caller attempted to spawn. Otherwise, this will spawn the future on the
executor and send back a [JoinHandle
] that the caller can .await
on
for the results of the Future
.
Trait Implementations§
source§impl Clone for BoundedExecutor
impl Clone for BoundedExecutor
source§fn clone(&self) -> BoundedExecutor
fn clone(&self) -> BoundedExecutor
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more