id stringlengths 22 133 | text stringlengths 40 40.2k | arch stringclasses 1
value | syntax stringclasses 1
value | kind stringclasses 4
values | repo stringclasses 27
values | path stringlengths 5 116 | license stringclasses 6
values | commit stringlengths 40 40 | source_host stringclasses 1
value | category stringclasses 16
values | source_url stringlengths 85 196 | line_start int64 1 4.28k | line_end int64 4 4.31k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokio-rs/tokio:tokio/src/runtime/context.rs:1 | //! Thread local runtime context
use crate::runtime::Handle;
use std::cell::RefCell;
thread_local! {
static CONTEXT: RefCell<Option<Handle>> = RefCell::new(None)
}
pub(crate) fn current() -> Option<Handle> {
CONTEXT.with(|ctx| ctx.borrow().clone())
}
cfg_io_driver! {
pub(crate) fn io_handle() -> crate::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 00b6127f2ed3125f8b305ab4fd9bb90e99762785 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/00b6127f2ed3125f8b305ab4fd9bb90e99762785/tokio/src/runtime/context.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context.rs:2 | cfg_test_util! {
pub(crate) fn clock() -> Option<crate::runtime::driver::Clock> {
CONTEXT.with(|ctx| match *ctx.borrow() {
Some(ref ctx) => Some(ctx.clock.clone()),
None => None,
})
}
}
}
cfg_rt! {
pub(crate) fn spawn_handle() -> Option<cr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | c90681bd8e629b5fde988b9f5be7b915e5cf8ae5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/runtime/context.rs | 41 | 83 |
tokio-rs/tokio:tokio/src/runtime/context.rs:1 | //! Thread local runtime context
use crate::runtime::Handle;
use std::cell::RefCell;
thread_local! {
static CONTEXT: RefCell<Option<Handle>> = RefCell::new(None)
}
pub(crate) fn current() -> Option<Handle> {
CONTEXT.with(|ctx| ctx.borrow().clone())
}
cfg_io_driver! {
pub(crate) fn io_handle() -> crate::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/context.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context.rs:2 | cfg_test_util! {
pub(crate) fn clock() -> Option<crate::runtime::driver::Clock> {
CONTEXT.with(|ctx| match *ctx.borrow() {
Some(ref ctx) => Some(ctx.clock.clone()),
None => None,
})
}
}
}
cfg_rt_core! {
pub(crate) fn spawn_handle() -> Opti... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/context.rs | 41 | 83 |
tokio-rs/tokio:tokio/src/runtime/context.rs:1 | //! Thread local runtime context
use crate::runtime::Handle;
use std::cell::RefCell;
thread_local! {
static CONTEXT: RefCell<Option<Handle>> = RefCell::new(None)
}
cfg_blocking_impl! {
pub(crate) fn current() -> Option<Handle> {
CONTEXT.with(|ctx| ctx.borrow().clone())
}
}
cfg_io_driver! {
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | a1d0681cd2e581b1f6767126858d2f3d5d8992f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a1d0681cd2e581b1f6767126858d2f3d5d8992f5/tokio/src/runtime/context.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context.rs:2 | }
cfg_test_util! {
pub(crate) fn clock() -> Option<crate::runtime::driver::Clock> {
CONTEXT.with(|ctx| match *ctx.borrow() {
Some(ref ctx) => Some(ctx.clock.clone()),
None => None,
})
}
}
}
cfg_rt_core! {
pub(crate) fn spawn_handle() ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | a1d0681cd2e581b1f6767126858d2f3d5d8992f5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a1d0681cd2e581b1f6767126858d2f3d5d8992f5/tokio/src/runtime/context.rs | 41 | 85 |
tokio-rs/tokio:tokio/src/runtime/context.rs:1 | //! Thread local runtime context
use crate::runtime::Handle;
use std::cell::RefCell;
thread_local! {
static CONTEXT: RefCell<Option<Handle>> = RefCell::new(None)
}
cfg_blocking_impl! {
pub(crate) fn current() -> Option<Handle> {
CONTEXT.with(|ctx| ctx.borrow().clone())
}
}
cfg_io_driver! {
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7ae5b7bd4f93612f91ab504ffb63aa8241c1d7bb/tokio/src/runtime/context.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context.rs:1 | //! Thread local runtime context
use crate::runtime::Handle;
use std::cell::RefCell;
thread_local! {
static CONTEXT: RefCell<Option<Handle>> = RefCell::new(None)
}
cfg_blocking_impl! {
pub(crate) fn current() -> Option<Handle> {
CONTEXT.with(|ctx| ctx.borrow().clone())
}
}
cfg_io_driver! {
p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/src/runtime/context.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context.rs:2 | }
cfg_rt_core! {
pub(crate) fn spawn_handle() -> Option<crate::runtime::Spawner> {
CONTEXT.with(|ctx| match *ctx.borrow() {
Some(ref ctx) => Some(ctx.spawner.clone()),
None => None,
})
}
}
/// Set this [`Handle`] as the current active [`Handle`].
///
/// [`Handle`]: Han... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | d600ab9a8f37e9eff3fa8587069a816b65b6da0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d600ab9a8f37e9eff3fa8587069a816b65b6da0b/tokio/src/runtime/context.rs | 41 | 75 |
tokio-rs/tokio:tokio/src/runtime/context.rs:1 | //! Thread local runtime context
use crate::runtime::Handle;
use std::cell::RefCell;
thread_local! {
static CONTEXT: RefCell<Option<Handle>> = RefCell::new(None)
}
pub(crate) fn current() -> Option<Handle> {
CONTEXT.with(|ctx| ctx.borrow().clone())
}
cfg_io_driver! {
pub(crate) fn io_handle() -> crate::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 28a93e604454d435476eb8bb2eee809fd86b001d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28a93e604454d435476eb8bb2eee809fd86b001d/tokio/src/runtime/context.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context.rs:2 | cfg_rt_core! {
pub(crate) fn spawn_handle() -> Option<crate::runtime::Spawner> {
CONTEXT.with(|ctx| match *ctx.borrow() {
Some(ref ctx) => Some(ctx.spawner.clone()),
None => None,
})
}
}
/// Set this [`Handle`] as the current active [`Handle`].
///
/// [`Handle`]: Handle... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 28a93e604454d435476eb8bb2eee809fd86b001d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/28a93e604454d435476eb8bb2eee809fd86b001d/tokio/src/runtime/context.rs | 41 | 73 |
tokio-rs/tokio:tokio/src/runtime/context.rs:1 | //! Thread local runtime context
use crate::runtime::Handle;
use std::cell::RefCell;
thread_local! {
static CONTEXT: RefCell<Option<Handle>> = RefCell::new(None)
}
pub(crate) fn current() -> Option<Handle> {
CONTEXT.with(|ctx| ctx.borrow().clone())
}
cfg_io_driver! {
pub(crate) fn io_handle() -> crate::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | f39c15334e74b07a44efaa0f7201262e17e4f062 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/runtime/context.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context.rs:2 | cfg_rt_core! {
pub(crate) fn spawn_handle() -> Option<crate::runtime::Spawner> {
CONTEXT.with(|ctx| match *ctx.borrow() {
Some(ref ctx) => Some(ctx.spawner.clone()),
None => None,
})
}
}
/// Set this [`ThreadContext`] as the current active [`ThreadContext`].
///
/// [`Th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | f39c15334e74b07a44efaa0f7201262e17e4f062 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/runtime/context.rs | 41 | 73 |
tokio-rs/tokio:tokio/src/runtime/context.rs:1 | //! Thread local runtime context
use crate::runtime::Handle;
use std::cell::RefCell;
thread_local! {
static CONTEXT: RefCell<Option<Handle>> = RefCell::new(None)
}
pub(crate) fn current() -> Option<Handle> {
CONTEXT.with(|ctx| ctx.borrow().clone())
}
cfg_io_driver! {
pub(crate) fn io_handle() -> crate::... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 45da5f3510a61599c89dc458ecc859f13a81e255 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/45da5f3510a61599c89dc458ecc859f13a81e255/tokio/src/runtime/context.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context.rs:2 | cfg_rt_core! {
pub(crate) fn spawn_handle() -> Option<crate::runtime::Spawner> {
CONTEXT.with(|ctx| match *ctx.borrow() {
Some(ref ctx) => Some(ctx.spawner.clone()),
None => None,
})
}
}
/// Set this [`ThreadContext`] as the current active [`ThreadContext`].
///
/// [`Th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 45da5f3510a61599c89dc458ecc859f13a81e255 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/45da5f3510a61599c89dc458ecc859f13a81e255/tokio/src/runtime/context.rs | 41 | 73 |
tokio-rs/tokio:tokio/src/runtime/context.rs:1 | //! Thread local runtime context
use crate::runtime::Spawner;
use std::cell::RefCell;
thread_local! {
static CONTEXT: RefCell<Option<ThreadContext>> = RefCell::new(None)
}
/// ThreadContext makes Runtime context accessible to each Runtime thread.
#[derive(Debug, Clone)]
pub(crate) struct ThreadContext {
/// H... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 0193df3a593cb69d23414109118784de2948024c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0193df3a593cb69d23414109118784de2948024c/tokio/src/runtime/context.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context.rs:2 | blocking_spawner: None,
}
}
}
impl ThreadContext {
/// Construct a new [`ThreadContext`]
///
/// [`ThreadContext`]: struct.ThreadContext.html
pub(crate) fn new(
spawner: Spawner,
io_handle: crate::runtime::io::Handle,
time_handle: crate::runtime::time::Handle,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 0193df3a593cb69d23414109118784de2948024c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0193df3a593cb69d23414109118784de2948024c/tokio/src/runtime/context.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/context.rs:3 | ///
/// [`ThreadContext`]: struct.ThreadContext.html
pub(crate) fn enter(self) -> ThreadContextDropGuard {
CONTEXT.with(|ctx| {
let previous = ctx.borrow_mut().replace(self);
ThreadContextDropGuard { previous }
})
}
pub(crate) fn io_handle() -> crate::runtime::io... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 0193df3a593cb69d23414109118784de2948024c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0193df3a593cb69d23414109118784de2948024c/tokio/src/runtime/context.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/context.rs:4 | CONTEXT.with(|ctx| {
match ctx
.borrow()
.as_ref()
.map(|ctx| ctx.blocking_spawner.clone())
{
Some(Some(blocking_spawner)) => Some(blocking_spawner),
_ => None,
}
})
}
}
cfg_blocking_impl! {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 0193df3a593cb69d23414109118784de2948024c | github | async-runtime | https://github.com/tokio-rs/tokio/blob/0193df3a593cb69d23414109118784de2948024c/tokio/src/runtime/context.rs | 121 | 161 |
tokio-rs/tokio:tokio/src/runtime/context.rs:1 | //! Thread local runtime context
use crate::runtime::Spawner;
use std::cell::RefCell;
thread_local! {
static CONTEXT: RefCell<Option<ThreadContext>> = RefCell::new(None)
}
/// ThreadContext makes Runtime context accessible to each Runtime thread.
#[derive(Debug, Clone)]
pub(crate) struct ThreadContext {
/// H... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | f0006006ed9938115011c42f26cff16842eb534f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/runtime/context.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context.rs:2 | impl ThreadContext {
/// Construct a new [`ThreadContext`]
///
/// [`ThreadContext`]: struct.ThreadContext.html
pub(crate) fn new(
spawner: Spawner,
io_handle: crate::runtime::io::Handle,
time_handle: crate::runtime::time::Handle,
clock: Option<crate::runtime::time::Clock... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | f0006006ed9938115011c42f26cff16842eb534f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/runtime/context.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/context.rs:3 | })
}
#[cfg(all(feature = "io-driver", not(loom)))]
pub(crate) fn io_handle() -> crate::runtime::io::Handle {
CONTEXT.with(|ctx| match *ctx.borrow() {
Some(ref ctx) => ctx.io_handle.clone(),
None => None,
})
}
#[cfg(all(feature = "time", not(loom)))]
pub(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | f0006006ed9938115011c42f26cff16842eb534f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/runtime/context.rs | 81 | 134 |
tokio-rs/tokio:tokio/src/runtime/context.rs:4 | /// [`ThreadContextDropGuard`]: struct.ThreadContextDropGuard.html
#[derive(Debug)]
pub(crate) struct ThreadContextDropGuard {
previous: Option<ThreadContext>,
}
impl Drop for ThreadContextDropGuard {
fn drop(&mut self) {
CONTEXT.with(|ctx| match self.previous.clone() {
Some(prev) => ctx.bo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | f0006006ed9938115011c42f26cff16842eb534f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f0006006ed9938115011c42f26cff16842eb534f/tokio/src/runtime/context.rs | 121 | 134 |
tokio-rs/tokio:tokio/src/runtime/context.rs:2 | impl ThreadContext {
/// Construct a new [`ThreadContext`]
///
/// [`ThreadContext`]: struct.ThreadContext.html
pub(crate) fn new(
spawner: Spawner,
io_handle: crate::runtime::io::Handle,
time_handle: crate::runtime::time::Handle,
clock: Option<crate::runtime::time::Clock... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 67bf9c36f347031ca05872d102a7f9abc8b465f0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/67bf9c36f347031ca05872d102a7f9abc8b465f0/tokio/src/runtime/context.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/context.rs:3 | })
}
#[cfg(all(feature = "test-util", feature = "time", test))]
pub(crate) fn with_time_handle(mut self, handle: crate::runtime::time::Handle) -> Self {
self.time_handle = handle;
self
}
#[cfg(all(feature = "test-util", feature = "time", test))]
pub(crate) fn with_clock(mut sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 67bf9c36f347031ca05872d102a7f9abc8b465f0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/67bf9c36f347031ca05872d102a7f9abc8b465f0/tokio/src/runtime/context.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/context.rs:4 | pub(crate) fn clock() -> Option<crate::runtime::time::Clock> {
CONTEXT.with(
|ctx| match ctx.borrow().as_ref().map(|ctx| ctx.clock.clone()) {
Some(Some(clock)) => Some(clock),
_ => None,
},
)
}
}
/// [`ThreadContextDropGuard`] will replace the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context.rs | MIT | 67bf9c36f347031ca05872d102a7f9abc8b465f0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/67bf9c36f347031ca05872d102a7f9abc8b465f0/tokio/src/runtime/context.rs | 121 | 146 |
tokio-rs/tokio:tokio/src/runtime/context/blocking.rs:1 | use super::{EnterRuntime, CONTEXT};
use crate::loom::thread::AccessError;
use crate::util::markers::NotSendOrSync;
use std::marker::PhantomData;
use std::time::Duration;
/// Guard tracking that a caller has entered a blocking region.
#[must_use]
pub(crate) struct BlockingRegionGuard {
_p: PhantomData<NotSendOrSy... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/blocking.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/blocking.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context/blocking.rs:2 | allow_block_in_place: false,
});
true
} else {
false
}
});
DisallowBlockInPlaceGuard(reset.unwrap_or(false))
}
impl BlockingRegionGuard {
pub(super) fn new() -> BlockingRegionGuard {
BlockingRegionGuard { _p: PhantomData }
}
/// Blocks t... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/blocking.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/blocking.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/context/blocking.rs:3 | let mut park = CachedParkThread::new();
let waker = park.waker().map_err(|_| ())?;
let mut cx = Context::from_waker(&waker);
pin!(f);
let when = Instant::now() + timeout;
loop {
if let Ready(v) = crate::task::coop::budget(|| f.as_mut().poll(&mut cx)) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/blocking.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/blocking.rs | 81 | 121 |
tokio-rs/tokio:tokio/src/runtime/context/blocking.rs:1 | use super::{EnterRuntime, CONTEXT};
use crate::loom::thread::AccessError;
use crate::util::markers::NotSendOrSync;
use std::marker::PhantomData;
use std::time::Duration;
/// Guard tracking that a caller has entered a blocking region.
#[must_use]
pub(crate) struct BlockingRegionGuard {
_p: PhantomData<NotSendOrSy... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/blocking.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/context/blocking.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context/blocking.rs:2 | allow_block_in_place: false,
});
true
} else {
false
}
});
DisallowBlockInPlaceGuard(reset)
}
impl BlockingRegionGuard {
pub(super) fn new() -> BlockingRegionGuard {
BlockingRegionGuard { _p: PhantomData }
}
/// Blocks the thread on the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/blocking.rs | MIT | 605ef578df04f12a951060dc3b2fb930f6f379fe | github | async-runtime | https://github.com/tokio-rs/tokio/blob/605ef578df04f12a951060dc3b2fb930f6f379fe/tokio/src/runtime/context/blocking.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/context/blocking.rs:2 | allow_block_in_place: false,
});
true
} else {
false
}
});
DisallowBlockInPlaceGuard(reset)
}
impl BlockingRegionGuard {
pub(super) fn new() -> BlockingRegionGuard {
BlockingRegionGuard { _p: PhantomData }
}
/// Blocks the thread on the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/blocking.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/context/blocking.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/context/blocking.rs:3 | let mut park = CachedParkThread::new();
let waker = park.waker().map_err(|_| ())?;
let mut cx = Context::from_waker(&waker);
pin!(f);
let when = Instant::now() + timeout;
loop {
if let Ready(v) = crate::runtime::coop::budget(|| f.as_mut().poll(&mut cx)) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/blocking.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/context/blocking.rs | 81 | 121 |
tokio-rs/tokio:tokio/src/runtime/context/blocking.rs:3 | let mut park = CachedParkThread::new();
let waker = park.waker().map_err(|_| ())?;
let mut cx = Context::from_waker(&waker);
pin!(f);
let when = Instant::now() + timeout;
loop {
if let Ready(v) = crate::runtime::coop::budget(|| f.as_mut().poll(&mut cx)) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/blocking.rs | MIT | 1204da730000f2eab19d2c05eea12ee3071b3f31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1204da730000f2eab19d2c05eea12ee3071b3f31/tokio/src/runtime/context/blocking.rs | 81 | 121 |
tokio-rs/tokio:tokio/src/runtime/context/current.rs:1 | use super::{Context, CONTEXT};
use crate::runtime::{scheduler, TryCurrentError};
use crate::util::markers::SyncNotSend;
use std::cell::{Cell, RefCell};
use std::marker::PhantomData;
#[derive(Debug)]
#[must_use]
pub(crate) struct SetCurrentGuard {
// The previous handle
prev: Option<scheduler::Handle>,
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/current.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/current.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context/current.rs:2 | match CONTEXT.try_with(|ctx| ctx.current.handle.borrow().as_ref().map(f)) {
Ok(Some(ret)) => Ok(ret),
Ok(None) => Err(TryCurrentError::new_no_context()),
Err(_access_error) => Err(TryCurrentError::new_thread_local_destroyed()),
}
}
impl Context {
pub(super) fn set_current(&self, handle:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/current.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/current.rs | 41 | 97 |
tokio-rs/tokio:tokio/src/runtime/context/current.rs:3 | if !std::thread::panicking() {
panic!(
"`EnterGuard` values dropped out of order. Guards returned by \
`tokio::runtime::Handle::enter()` must be dropped in the reverse \
order as they were acquired."
);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/current.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/current.rs | 81 | 97 |
tokio-rs/tokio:tokio/src/runtime/context/current.rs:1 | use super::{Context, CONTEXT};
use crate::runtime::{scheduler, TryCurrentError};
use crate::util::markers::SyncNotSend;
use std::cell::{Cell, RefCell};
use std::marker::PhantomData;
#[derive(Debug)]
#[must_use]
pub(crate) struct SetCurrentGuard {
// The previous handle
prev: Option<scheduler::Handle>,
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/current.rs | MIT | cbb3c155dd416f6e6a26be5e3b2ebc02853e4b62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbb3c155dd416f6e6a26be5e3b2ebc02853e4b62/tokio/src/runtime/context/current.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context/current.rs:2 | match CONTEXT.try_with(|ctx| ctx.current.handle.borrow().as_ref().map(f)) {
Ok(Some(ret)) => Ok(ret),
Ok(None) => Err(TryCurrentError::new_no_context()),
Err(_access_error) => Err(TryCurrentError::new_thread_local_destroyed()),
}
}
impl Context {
pub(super) fn set_current(&self, handle:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/current.rs | MIT | cbb3c155dd416f6e6a26be5e3b2ebc02853e4b62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbb3c155dd416f6e6a26be5e3b2ebc02853e4b62/tokio/src/runtime/context/current.rs | 41 | 99 |
tokio-rs/tokio:tokio/src/runtime/context/current.rs:3 | if depth != self.depth {
if !std::thread::panicking() {
panic!(
"`EnterGuard` values dropped out of order. Guards returned by \
`tokio::runtime::Handle::enter()` must be dropped in the reverse \
order as they w... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/current.rs | MIT | cbb3c155dd416f6e6a26be5e3b2ebc02853e4b62 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbb3c155dd416f6e6a26be5e3b2ebc02853e4b62/tokio/src/runtime/context/current.rs | 81 | 99 |
tokio-rs/tokio:tokio/src/runtime/context/current.rs:1 | use super::{Context, CONTEXT};
use crate::runtime::{scheduler, TryCurrentError};
use crate::util::markers::SyncNotSend;
use std::marker::PhantomData;
#[derive(Debug)]
#[must_use]
pub(crate) struct SetCurrentGuard {
old_handle: Option<scheduler::Handle>,
_p: PhantomData<SyncNotSend>,
}
/// Sets this [`Handle... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/current.rs | MIT | 1204da730000f2eab19d2c05eea12ee3071b3f31 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1204da730000f2eab19d2c05eea12ee3071b3f31/tokio/src/runtime/context/current.rs | 1 | 59 |
tokio-rs/tokio:tokio/src/runtime/context/runtime.rs:1 | use super::{BlockingRegionGuard, SetCurrentGuard, CONTEXT};
use crate::runtime::scheduler;
use crate::util::rand::{FastRand, RngSeed};
use std::fmt;
#[derive(Debug, Clone, Copy)]
#[must_use]
pub(crate) enum EnterRuntime {
/// Currently in a runtime context.
#[cfg_attr(not(feature = "rt"), allow(dead_code))]
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/runtime.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/runtime.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/context/runtime.rs:2 | None
} else {
// Set the entered flag
c.runtime.set(EnterRuntime::Entered {
allow_block_in_place,
});
// Generate a new seed
let rng_seed = handle.seed_generator().next_seed();
// Swap the RNG seed
let mut rng ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/runtime.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/runtime.rs | 41 | 99 |
tokio-rs/tokio:tokio/src/runtime/context/runtime.rs:3 | impl Drop for EnterRuntimeGuard {
fn drop(&mut self) {
CONTEXT.with(|c| {
assert!(c.runtime.get().is_entered());
c.runtime.set(EnterRuntime::NotEntered);
// Replace the previous RNG seed
let mut rng = c.rng.get().unwrap_or_else(FastRand::new);
rng.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/runtime.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/runtime.rs | 81 | 99 |
tokio-rs/tokio:tokio/src/runtime/context/runtime_mt.rs:1 | use super::{EnterRuntime, CONTEXT};
/// Returns true if in a runtime context.
pub(crate) fn current_enter_context() -> EnterRuntime {
CONTEXT.with(|c| c.runtime.get())
}
/// Forces the current "entered" state to be cleared while the closure
/// is executed.
pub(crate) fn exit_runtime<F: FnOnce() -> R, R>(f: F) ->... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/runtime_mt.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/runtime_mt.rs | 1 | 36 |
tokio-rs/tokio:tokio/src/runtime/context/scoped.rs:1 | use std::cell::Cell;
use std::ptr;
/// Scoped thread-local storage
pub(super) struct Scoped<T> {
pub(super) inner: Cell<*const T>,
}
impl<T> Scoped<T> {
pub(super) const fn new() -> Scoped<T> {
Scoped {
inner: Cell::new(ptr::null()),
}
}
/// Inserts a value into the scoped... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/scoped.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/context/scoped.rs | 1 | 56 |
tokio-rs/tokio:tokio/src/runtime/context/scoped.rs:1 | use std::cell::Cell;
use std::ptr;
/// Scoped thread-local storage
pub(super) struct Scoped<T> {
pub(super) inner: Cell<*const T>,
}
unsafe impl<T> Sync for Scoped<T> {}
impl<T> Scoped<T> {
pub(super) const fn new() -> Scoped<T> {
Scoped {
inner: Cell::new(ptr::null()),
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/scoped.rs | MIT | 8f0103f6c5fd300fee15888fc15ec9dd86248690 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8f0103f6c5fd300fee15888fc15ec9dd86248690/tokio/src/runtime/context/scoped.rs | 1 | 58 |
tokio-rs/tokio:tokio/src/runtime/context/scoped.rs:1 | use std::cell::Cell;
use std::ptr;
/// Scoped thread-local storage
pub(super) struct Scoped<T> {
pub(super) inner: Cell<*const T>,
}
unsafe impl<T> Sync for Scoped<T> {}
impl<T> Scoped<T> {
pub(super) fn new() -> Scoped<T> {
Scoped {
inner: Cell::new(ptr::null()),
}
}
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/context/scoped.rs | MIT | 9f9db7da6340a76938427425c57fe781276d4299 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9f9db7da6340a76938427425c57fe781276d4299/tokio/src/runtime/context/scoped.rs | 1 | 58 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:1 | #![cfg_attr(not(feature = "full"), allow(dead_code))]
//! Yield points for improved cooperative scheduling.
//!
//! Documentation for this can be found in the [`tokio::task`] module.
//!
//! [`tokio::task`]: crate::task.
// ```ignore
// # use tokio_stream::{Stream, StreamExt};
// async fn drop_all<I: Stream + Unpin>(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | c8af499990d739f4e849bf33c1e1fa4b353f5958 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8af499990d739f4e849bf33c1e1fa4b353f5958/tokio/src/runtime/coop.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:2 | hit_zero: bool,
}
impl Budget {
/// Budget assigned to a task on each poll.
///
/// The value itself is chosen somewhat arbitrarily. It needs to be high
/// enough to amortize wakeup and scheduling costs, but low enough that we
/// do not starve other tasks for too long. The value also needs to be ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | c8af499990d739f4e849bf33c1e1fa4b353f5958 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8af499990d739f4e849bf33c1e1fa4b353f5958/tokio/src/runtime/coop.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:3 | }
#[inline(always)]
fn with_budget<R>(budget: Budget, f: impl FnOnce() -> R) -> R {
struct ResetGuard {
prev: Budget,
}
impl Drop for ResetGuard {
fn drop(&mut self) {
let _ = context::budget(|cell| {
cell.set(self.prev);
});
}
}
#[a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | c8af499990d739f4e849bf33c1e1fa4b353f5958 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8af499990d739f4e849bf33c1e1fa4b353f5958/tokio/src/runtime/coop.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:4 | }
}
cfg_rt! {
/// Forcibly removes the budgeting constraints early.
///
/// Returns the remaining budget
pub(crate) fn stop() -> Budget {
context::budget(|cell| {
let prev = cell.get();
cell.set(Budget::unconstrained());
prev
}).unwrap_or(Budget::unco... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | c8af499990d739f4e849bf33c1e1fa4b353f5958 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8af499990d739f4e849bf33c1e1fa4b353f5958/tokio/src/runtime/coop.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:5 | });
}
}
}
/// Returns `Poll::Pending` if the current task has exceeded its budget and should yield.
///
/// When you call this method, the current budget is decremented. However, to ensure that
/// progress is made every time a task is polled, the budget is automatically restore... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | c8af499990d739f4e849bf33c1e1fa4b353f5958 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8af499990d739f4e849bf33c1e1fa4b353f5958/tokio/src/runtime/coop.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:6 | cfg_rt! {
cfg_unstable_metrics! {
#[inline(always)]
fn inc_budget_forced_yield_count() {
let _ = context::with_current(|handle| {
handle.scheduler_metrics().inc_budget_forced_yield_count();
});
}
}
cfg_not_u... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | c8af499990d739f4e849bf33c1e1fa4b353f5958 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c8af499990d739f4e849bf33c1e1fa4b353f5958/tokio/src/runtime/coop.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:3 | }
#[inline(always)]
fn with_budget<R>(budget: Budget, f: impl FnOnce() -> R) -> R {
struct ResetGuard {
prev: Budget,
}
impl Drop for ResetGuard {
fn drop(&mut self) {
let _ = context::budget(|cell| {
cell.set(self.prev);
});
}
}
#[a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/coop.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:4 | }
}
cfg_rt! {
/// Forcibly removes the budgeting constraints early.
///
/// Returns the remaining budget
pub(crate) fn stop() -> Budget {
context::budget(|cell| {
let prev = cell.get();
cell.set(Budget::unconstrained());
prev
}).unwrap_or(Budget::unco... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/coop.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:5 | }
/// Returns `Poll::Pending` if the current task has exceeded its budget and should yield.
///
/// When you call this method, the current budget is decremented. However, to ensure that
/// progress is made every time a task is polled, the budget is automatically restored to its
/// former value if... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/coop.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:6 | #[inline(always)]
fn inc_budget_forced_yield_count() {
let _ = context::with_current(|handle| {
handle.scheduler_metrics().inc_budget_forced_yield_count();
});
}
}
cfg_not_unstable_metrics! {
#[inline(always)]
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/coop.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:7 | }
}
}
#[cfg(all(test, not(loom)))]
mod test {
use super::*;
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
fn get() -> Budget {
context::budget(|cell| cell.get()).unwrap_or(Budget::unconstrained())
}
#[test]
fn b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/coop.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:8 | drop(coop);
// we _did_ make progress
assert_eq!(get().0.unwrap(), Budget::initial().0.unwrap() - 1);
let coop = assert_ready!(task::spawn(()).enter(|cx, _| poll_proceed(cx)));
assert_eq!(get().0.unwrap(), Budget::initial().0.unwrap() - 2);
coop.made_progress... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 12b2567b959ec754e6f58fb76b88a1a38f805771 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/12b2567b959ec754e6f58fb76b88a1a38f805771/tokio/src/runtime/coop.rs | 281 | 323 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:6 | #[inline(always)]
fn inc_budget_forced_yield_count() {
let _ = context::with_current(|handle| {
handle.scheduler_metrics().inc_budget_forced_yield_count();
});
}
}
cfg_not_unstable_metrics! {
#[inline(always)]
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/coop.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:7 | }
}
}
#[cfg(all(test, not(loom)))]
mod test {
use super::*;
#[cfg(all(target_family = "wasm", not(target_os = "wasi")))]
use wasm_bindgen_test::wasm_bindgen_test as test;
fn get() -> Budget {
context::budget(|cell| cell.get()).unwrap_or(Budget::unconstrained())
}
#[test]
fn b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 11f66f43a09169b893212b854c6c49985ff2224f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/runtime/coop.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:8 | drop(coop);
// we _did_ make progress
assert_eq!(get().0.unwrap(), Budget::initial().0.unwrap() - 1);
let coop = assert_ready!(task::spawn(()).enter(|cx, _| poll_proceed(cx)));
assert_eq!(get().0.unwrap(), Budget::initial().0.unwrap() - 2);
coop.made_progress... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 86658bd87dc470f8e36eb6b893cc403820cfb7ee | github | async-runtime | https://github.com/tokio-rs/tokio/blob/86658bd87dc470f8e36eb6b893cc403820cfb7ee/tokio/src/runtime/coop.rs | 281 | 323 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:5 | }
/// Returns `Poll::Pending` if the current task has exceeded its budget and should yield.
///
/// When you call this method, the current budget is decremented. However, to ensure that
/// progress is made every time a task is polled, the budget is automatically restored to its
/// former value if... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/coop.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:6 | #[inline(always)]
fn inc_budget_forced_yield_count() {
let _ = context::with_current(|handle| {
handle.scheduler_metrics().inc_budget_forced_yield_count();
});
}
}
cfg_not_metrics! {
#[inline(always)]
fn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/runtime/coop.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:2 | hit_zero: bool,
}
impl Budget {
/// Budget assigned to a task on each poll.
///
/// The value itself is chosen somewhat arbitrarily. It needs to be high
/// enough to amortize wakeup and scheduling costs, but low enough that we
/// do not starve other tasks for too long. The value also needs to be ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | c445e467ce4363b3a9b6825268814a9bc27c0127 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c445e467ce4363b3a9b6825268814a9bc27c0127/tokio/src/runtime/coop.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:6 | #[inline(always)]
fn inc_budget_forced_yield_count() {
let _ = context::with_current(|handle| {
handle.scheduler_metrics().inc_budget_forced_yield_count();
});
}
}
cfg_not_metrics! {
#[inline(always)]
fn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | d274ef3748b82d7d7eccc39a8482586a4d8a5cc1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d274ef3748b82d7d7eccc39a8482586a4d8a5cc1/tokio/src/runtime/coop.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:7 | }
}
}
#[cfg(all(test, not(loom)))]
mod test {
use super::*;
#[cfg(tokio_wasm_not_wasi)]
use wasm_bindgen_test::wasm_bindgen_test as test;
fn get() -> Budget {
context::budget(|cell| cell.get()).unwrap_or(Budget::unconstrained())
}
#[test]
fn budgeting() {
use futures:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | d274ef3748b82d7d7eccc39a8482586a4d8a5cc1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d274ef3748b82d7d7eccc39a8482586a4d8a5cc1/tokio/src/runtime/coop.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:5 | }
/// Returns `Poll::Pending` if the current task has exceeded its budget and should yield.
///
/// When you call this method, the current budget is decremented. However, to ensure that
/// progress is made every time a task is polled, the budget is automatically restored to its
/// former value if... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 9eb3f5b556c1484f17368b193001ce972219d980 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9eb3f5b556c1484f17368b193001ce972219d980/tokio/src/runtime/coop.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:6 | #[inline(always)]
fn inc_budget_forced_yield_count() {
if let Ok(handle) = context::try_current() {
handle.scheduler_metrics().inc_budget_forced_yield_count();
}
}
}
cfg_not_metrics! {
#[inline(always)]
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 9eb3f5b556c1484f17368b193001ce972219d980 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/9eb3f5b556c1484f17368b193001ce972219d980/tokio/src/runtime/coop.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:3 | }
#[inline(always)]
fn with_budget<R>(budget: Budget, f: impl FnOnce() -> R) -> R {
struct ResetGuard {
prev: Budget,
}
impl Drop for ResetGuard {
fn drop(&mut self) {
let _ = context::budget(|cell| {
cell.set(self.prev);
});
}
}
#[a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 70364b707975b84daf223915d60a1610de2539a2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/70364b707975b84daf223915d60a1610de2539a2/tokio/src/runtime/coop.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:4 | }
/// Consume one unit of progress from the current task's budget.
pub(crate) fn consume_one() {
let _ = context::budget(|cell| {
let mut budget = cell.get();
if let Some(ref mut counter) = budget.0 {
*counter = counter.saturating_sub(1);
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 70364b707975b84daf223915d60a1610de2539a2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/70364b707975b84daf223915d60a1610de2539a2/tokio/src/runtime/coop.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:5 | impl Drop for RestoreOnPending {
fn drop(&mut self) {
// Don't reset if budget was unconstrained or if we made progress.
// They are both represented as the remembered budget being unconstrained.
let budget = self.0.get();
if !budget.is_unconstrained() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 70364b707975b84daf223915d60a1610de2539a2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/70364b707975b84daf223915d60a1610de2539a2/tokio/src/runtime/coop.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:6 | Poll::Ready(restore)
} else {
cx.waker().wake_by_ref();
Poll::Pending
}
}).unwrap_or(Poll::Ready(RestoreOnPending(Cell::new(Budget::unconstrained()))))
}
cfg_rt! {
cfg_metrics! {
#[inline(always)]
fn inc_budget_forc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 70364b707975b84daf223915d60a1610de2539a2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/70364b707975b84daf223915d60a1610de2539a2/tokio/src/runtime/coop.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:7 | BudgetDecrement { success: true, hit_zero }
} else {
BudgetDecrement { success: false, hit_zero: false }
}
} else {
BudgetDecrement { success: true, hit_zero: false }
}
}
fn is_unconstrained(self) -> bool {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 70364b707975b84daf223915d60a1610de2539a2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/70364b707975b84daf223915d60a1610de2539a2/tokio/src/runtime/coop.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:8 | assert_eq!(get().0, Budget::initial().0);
let coop = assert_ready!(task::spawn(()).enter(|cx, _| poll_proceed(cx)));
assert_eq!(get().0.unwrap(), Budget::initial().0.unwrap() - 1);
drop(coop);
// we didn't make progress
assert_eq!(get().0, Budget::initial().0... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 70364b707975b84daf223915d60a1610de2539a2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/70364b707975b84daf223915d60a1610de2539a2/tokio/src/runtime/coop.rs | 281 | 334 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:9 | let coop = assert_ready!(task::spawn(()).enter(|cx, _| poll_proceed(cx)));
coop.made_progress();
}
let mut task = task::spawn(poll_fn(|cx| {
let coop = ready!(poll_proceed(cx));
coop.made_progress();
Poll::Ready(())
}))... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 70364b707975b84daf223915d60a1610de2539a2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/70364b707975b84daf223915d60a1610de2539a2/tokio/src/runtime/coop.rs | 321 | 334 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:4 | }
}
cfg_rt! {
/// Forcibly removes the budgeting constraints early.
///
/// Returns the remaining budget
pub(crate) fn stop() -> Budget {
context::budget(|cell| {
let prev = cell.get();
cell.set(Budget::unconstrained());
prev
}).unwrap_or(Budget::unco... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 52da177dea169aa9f3dac6b1465fa5229a9615bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/src/runtime/coop.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:5 | }
/// Returns `Poll::Pending` if the current task has exceeded its budget and should yield.
///
/// When you call this method, the current budget is decremented. However, to ensure that
/// progress is made every time a task is polled, the budget is automatically restored to its
/// former value if... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | 52da177dea169aa9f3dac6b1465fa5229a9615bb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/52da177dea169aa9f3dac6b1465fa5229a9615bb/tokio/src/runtime/coop.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:1 | #![cfg_attr(not(feature = "full"), allow(dead_code))]
//! Yield points for improved cooperative scheduling.
//!
//! Documentation for this can be found in the [`tokio::task`] module.
//!
//! [`tokio::task`]: crate::task.
// ```ignore
// # use tokio_stream::{Stream, StreamExt};
// async fn drop_all<I: Stream + Unpin>(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | b7812c85ca2d051d47cec023b880cbf8cdcbc313 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/src/runtime/coop.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:2 | ///
/// The value itself is chosen somewhat arbitrarily. It needs to be high
/// enough to amortize wakeup and scheduling costs, but low enough that we
/// do not starve other tasks for too long. The value also needs to be high
/// enough that particularly deep tasks are able to do at least some useful
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | b7812c85ca2d051d47cec023b880cbf8cdcbc313 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/src/runtime/coop.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:3 | prev: Budget,
}
impl Drop for ResetGuard {
fn drop(&mut self) {
let _ = context::budget(|cell| {
cell.set(self.prev);
});
}
}
#[allow(unused_variables)]
let maybe_guard = context::budget(|cell| {
let prev = cell.get();
cell.se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | b7812c85ca2d051d47cec023b880cbf8cdcbc313 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/src/runtime/coop.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:4 | ///
/// Returns the remaining budget
pub(crate) fn stop() -> Budget {
context::budget(|cell| {
let prev = cell.get();
cell.set(Budget::unconstrained());
prev
}).unwrap_or(Budget::unconstrained())
}
}
cfg_coop! {
use std::cell::Cell;
use std::task:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | b7812c85ca2d051d47cec023b880cbf8cdcbc313 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/src/runtime/coop.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:5 | /// progress is made every time a task is polled, the budget is automatically restored to its
/// former value if the returned `RestoreOnPending` is dropped. It is the caller's
/// responsibility to call `RestoreOnPending::made_progress` if it made progress, to ensure
/// that the budget empties appropriate... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | b7812c85ca2d051d47cec023b880cbf8cdcbc313 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/src/runtime/coop.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:6 | fn is_unconstrained(self) -> bool {
self.0.is_none()
}
}
}
#[cfg(all(test, not(loom)))]
mod test {
use super::*;
#[cfg(tokio_wasm_not_wasi)]
use wasm_bindgen_test::wasm_bindgen_test as test;
fn get() -> Budget {
context::budget(|cell| cell.get()).unwrap_or(Budget::unco... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | b7812c85ca2d051d47cec023b880cbf8cdcbc313 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/src/runtime/coop.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:7 | let coop = assert_ready!(task::spawn(()).enter(|cx, _| poll_proceed(cx)));
assert_eq!(get().0.unwrap(), Budget::initial().0.unwrap() - 1);
coop.made_progress();
drop(coop);
// we _did_ make progress
assert_eq!(get().0.unwrap(), Budget::initial().0.unwrap() - 1... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | b7812c85ca2d051d47cec023b880cbf8cdcbc313 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b7812c85ca2d051d47cec023b880cbf8cdcbc313/tokio/src/runtime/coop.rs | 241 | 286 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:2 | impl Budget {
/// Budget assigned to a task on each poll.
///
/// The value itself is chosen somewhat arbitrarily. It needs to be high
/// enough to amortize wakeup and scheduling costs, but low enough that we
/// do not starve other tasks for too long. The value also needs to be high
/// enough... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | d8ee2055304e4fcd875d5cec4ed27e8070cc0306 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8ee2055304e4fcd875d5cec4ed27e8070cc0306/tokio/src/runtime/coop.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:3 | fn with_budget<R>(budget: Budget, f: impl FnOnce() -> R) -> R {
struct ResetGuard<'a> {
cell: &'a Cell<Budget>,
prev: Budget,
}
impl<'a> Drop for ResetGuard<'a> {
fn drop(&mut self) {
self.cell.set(self.prev);
}
}
context::budget(|cell| {
let pre... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | d8ee2055304e4fcd875d5cec4ed27e8070cc0306 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8ee2055304e4fcd875d5cec4ed27e8070cc0306/tokio/src/runtime/coop.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:4 | context::budget(|cell| {
let prev = cell.get();
cell.set(Budget::unconstrained());
prev
})
}
}
cfg_coop! {
use std::task::{Context, Poll};
#[must_use]
pub(crate) struct RestoreOnPending(Cell<Budget>);
impl RestoreOnPending {
pub(crate) fn made_p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | d8ee2055304e4fcd875d5cec4ed27e8070cc0306 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8ee2055304e4fcd875d5cec4ed27e8070cc0306/tokio/src/runtime/coop.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:5 | ///
/// Note that `RestoreOnPending` restores the budget **as it was before `poll_proceed`**.
/// Therefore, if the budget is _fCURRENT.withurther_ adjusted between when `poll_proceed` returns and
/// `RestRestoreOnPending` is dropped, those adjustments are erased unless the caller indicates
/// that pr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | d8ee2055304e4fcd875d5cec4ed27e8070cc0306 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8ee2055304e4fcd875d5cec4ed27e8070cc0306/tokio/src/runtime/coop.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:6 | }
}
#[cfg(all(test, not(loom)))]
mod test {
use super::*;
#[cfg(tokio_wasm_not_wasi)]
use wasm_bindgen_test::wasm_bindgen_test as test;
fn get() -> Budget {
context::budget(|cell| cell.get())
}
#[test]
fn budgeting() {
use futures::future::poll_fn;
use tokio_test:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | d8ee2055304e4fcd875d5cec4ed27e8070cc0306 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8ee2055304e4fcd875d5cec4ed27e8070cc0306/tokio/src/runtime/coop.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/coop.rs:7 | // we _did_ make progress
assert_eq!(get().0.unwrap(), Budget::initial().0.unwrap() - 1);
let coop = assert_ready!(task::spawn(()).enter(|cx, _| poll_proceed(cx)));
assert_eq!(get().0.unwrap(), Budget::initial().0.unwrap() - 2);
coop.made_progress();
drop(coo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/coop.rs | MIT | d8ee2055304e4fcd875d5cec4ed27e8070cc0306 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8ee2055304e4fcd875d5cec4ed27e8070cc0306/tokio/src/runtime/coop.rs | 241 | 282 |
tokio-rs/tokio:tokio/src/runtime/current_thread/async_await.rs:1 | use std::future::Future;
use super::Runtime;
impl Runtime {
/// Like `block_on`, but takes an `async` block
pub fn block_on_async<F>(&mut self, future: F) -> F::Output
where
F: Future,
{
use tokio_futures::compat;
match self.block_on(compat::infallible_into_01(future)) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/current_thread/async_await.rs | MIT | cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cb4aea394e6851ae8cc45a68beeaf2c93cc9a0c0/tokio/src/runtime/current_thread/async_await.rs | 1 | 17 |
tokio-rs/tokio:tokio/src/runtime/current_thread/async_await.rs:1 | use super::Runtime;
use std::future::Future;
impl Runtime {
/// Like `block_on`, but takes an `async` block
pub fn block_on_async<F>(&mut self, future: F) -> F::Output
where
F: Future,
{
use tokio_futures::compat;
match self.block_on(compat::infallible_into_01(future)) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/current_thread/async_await.rs | MIT | 4ef736b9d5ac41b2548eaf7c59a00a63b2633ba4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4ef736b9d5ac41b2548eaf7c59a00a63b2633ba4/tokio/src/runtime/current_thread/async_await.rs | 1 | 17 |
tokio-rs/tokio:tokio/src/runtime/current_thread/builder.rs:1 | use crate::executor::current_thread::CurrentThread;
use crate::net::driver::Reactor;
use crate::runtime::current_thread::Runtime;
use crate::timer::clock::Clock;
use crate::timer::timer::Timer;
use std::io;
/// Builds a Single-threaded runtime with custom configuration values.
///
/// Methods can be chained in order ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/current_thread/builder.rs | MIT | c62ef2d232dea1535a8e22484fa2ca083f03e903 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/src/runtime/current_thread/builder.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/current_thread/builder.rs:2 | }
impl Builder {
/// Returns a new runtime builder initialized with default configuration
/// values.
///
/// Configuration methods can be chained on the return value.
pub fn new() -> Builder {
Builder {
clock: Clock::new(),
}
}
/// Set the `Clock` instance that... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/current_thread/builder.rs | MIT | c62ef2d232dea1535a8e22484fa2ca083f03e903 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/src/runtime/current_thread/builder.rs | 41 | 91 |
tokio-rs/tokio:tokio/src/runtime/current_thread/builder.rs:3 | );
Ok(runtime)
}
}
impl Default for Builder {
fn default() -> Self {
Self::new()
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/current_thread/builder.rs | MIT | c62ef2d232dea1535a8e22484fa2ca083f03e903 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c62ef2d232dea1535a8e22484fa2ca083f03e903/tokio/src/runtime/current_thread/builder.rs | 81 | 91 |
tokio-rs/tokio:tokio/src/runtime/current_thread/builder.rs:1 | use crate::net::driver::Reactor;
use crate::runtime::current_thread::Runtime;
use crate::timer::clock::Clock;
use crate::timer::timer::Timer;
use tokio_executor::current_thread::CurrentThread;
use std::io;
/// Builds a Single-threaded runtime with custom configuration values.
///
/// Methods can be chained in order ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/current_thread/builder.rs | MIT | 227533d456fe32e48ffcd3796f1e6c8f9318b230 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/227533d456fe32e48ffcd3796f1e6c8f9318b230/tokio/src/runtime/current_thread/builder.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/current_thread/builder.rs:2 | clock: Clock,
}
impl Builder {
/// Returns a new runtime builder initialized with default configuration
/// values.
///
/// Configuration methods can be chained on the return value.
pub fn new() -> Builder {
Builder {
clock: Clock::new(),
}
}
/// Set the `Clock`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/current_thread/builder.rs | MIT | 227533d456fe32e48ffcd3796f1e6c8f9318b230 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/227533d456fe32e48ffcd3796f1e6c8f9318b230/tokio/src/runtime/current_thread/builder.rs | 41 | 92 |
tokio-rs/tokio:tokio/src/runtime/current_thread/builder.rs:3 | executor,
);
Ok(runtime)
}
}
impl Default for Builder {
fn default() -> Self {
Self::new()
}
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/current_thread/builder.rs | MIT | 227533d456fe32e48ffcd3796f1e6c8f9318b230 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/227533d456fe32e48ffcd3796f1e6c8f9318b230/tokio/src/runtime/current_thread/builder.rs | 81 | 92 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.