diff options
author | Carl Lerche <me@carllerche.com> | 2019-11-16 22:24:28 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-16 22:24:28 -0800 |
commit | 4d19a999371190e25f6138916d93e6c75093e4a6 (patch) | |
tree | 3121b6225abeab50448bad562ac30b0eb8da20a1 /tokio/src/runtime/basic_scheduler.rs | |
parent | 10dc659450d83c21de9661fc084ae83b4878098b (diff) |
runtime: set spawn context on enter (#1780)
Diffstat (limited to 'tokio/src/runtime/basic_scheduler.rs')
-rw-r--r-- | tokio/src/runtime/basic_scheduler.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tokio/src/runtime/basic_scheduler.rs b/tokio/src/runtime/basic_scheduler.rs index cb99cf18..affe2a5e 100644 --- a/tokio/src/runtime/basic_scheduler.rs +++ b/tokio/src/runtime/basic_scheduler.rs @@ -179,6 +179,15 @@ impl Spawner { self.scheduler.schedule(task); handle } + + /// Enter the executor context + pub(crate) fn enter<F, R>(&self, f: F) -> R + where + F: FnOnce() -> R, + { + use crate::runtime::global; + global::with_basic_scheduler(&*self.scheduler, f) + } } impl SchedulerPriv { |