add Executor::is_empty and LocalExecutor::is_empty
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
This commit is contained in:
parent
29ba8a72ad
commit
5a5ecd2763
10
src/lib.rs
10
src/lib.rs
|
@ -214,6 +214,11 @@ impl<'a> Executor<'a> {
|
|||
future.or(run_forever).await
|
||||
}
|
||||
|
||||
/// Checks if the executor is empty and has no pending tasks to run.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.state().active.lock().unwrap().is_empty()
|
||||
}
|
||||
|
||||
/// Returns a function that schedules a runnable task when it gets woken up.
|
||||
fn schedule(&self) -> impl Fn(Runnable) + Send + Sync + 'static {
|
||||
let state = self.state().clone();
|
||||
|
@ -393,6 +398,11 @@ impl<'a> LocalExecutor<'a> {
|
|||
self.inner().run(future).await
|
||||
}
|
||||
|
||||
/// Checks if the executor is empty and has no pending tasks to run.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.inner().is_empty()
|
||||
}
|
||||
|
||||
/// Returns a function that schedules a runnable task when it gets woken up.
|
||||
fn schedule(&self) -> impl Fn(Runnable) + Send + Sync + 'static {
|
||||
let state = self.inner().state().clone();
|
||||
|
|
Loading…
Reference in New Issue