File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,11 @@ impl<'a> Executor<'a> {
214
214
future. or ( run_forever) . await
215
215
}
216
216
217
+ /// Checks if the executor is empty and has no pending tasks to run.
218
+ pub fn is_empty ( & self ) -> bool {
219
+ self . state ( ) . active . lock ( ) . unwrap ( ) . is_empty ( )
220
+ }
221
+
217
222
/// Returns a function that schedules a runnable task when it gets woken up.
218
223
fn schedule ( & self ) -> impl Fn ( Runnable ) + Send + Sync + ' static {
219
224
let state = self . state ( ) . clone ( ) ;
@@ -393,6 +398,11 @@ impl<'a> LocalExecutor<'a> {
393
398
self . inner ( ) . run ( future) . await
394
399
}
395
400
401
+ /// Checks if the executor is empty and has no pending tasks to run.
402
+ pub fn is_empty ( & self ) -> bool {
403
+ self . inner ( ) . is_empty ( )
404
+ }
405
+
396
406
/// Returns a function that schedules a runnable task when it gets woken up.
397
407
fn schedule ( & self ) -> impl Fn ( Runnable ) + Send + Sync + ' static {
398
408
let state = self . inner ( ) . state ( ) . clone ( ) ;
You can’t perform that action at this time.
0 commit comments