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/task/task_local.rs:5
/// # Panics /// /// This function will panic if not called within the context /// of a future containing a task-local with the corresponding key. pub fn with<F, R>(&'static self, f: F) -> R where F: FnOnce(&T) -> R, { self.try_with(f).expect( "cannot access a Task Lo...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
c659e4a757b5a2a63378ead33917f4e072dba5dc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c659e4a757b5a2a63378ead33917f4e072dba5dc/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:3
/// assert_eq!(NUMBER.get(), 1); /// }).await; /// /// NUMBER.scope(2, async move { /// assert_eq!(NUMBER.get(), 2); /// /// NUMBER.scope(3, async move { /// assert_eq!(NUMBER.get(), 3); /// }).await; /// }).await; /// # } /// ``` /// [`std::thread::LocalKey`]: struct@std::thread::LocalKey #[cfg...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
ce0e9c67cfe61c7a91a284331ecc53fa01c32879
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ce0e9c67cfe61c7a91a284331ecc53fa01c32879/tokio/src/task/task_local.rs
81
140
tokio-rs/tokio:tokio/src/task/task_local.rs:4
{ TaskLocalFuture { local: &self, slot: Some(value), future: f, } .await } /// Accesses the current task-local and runs the provided closure. /// /// # Panics /// /// This function will panic if not called within the context /// of...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
ce0e9c67cfe61c7a91a284331ecc53fa01c32879
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ce0e9c67cfe61c7a91a284331ecc53fa01c32879/tokio/src/task/task_local.rs
121
180
tokio-rs/tokio:tokio/src/task/task_local.rs:5
}) } } impl<T: Copy + 'static> LocalKey<T> { /// Returns a copy of the task-local value /// if the task-local value implements `Copy`. pub fn get(&'static self) -> T { self.with(|v| *v) } } impl<T: 'static> fmt::Debug for LocalKey<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
ce0e9c67cfe61c7a91a284331ecc53fa01c32879
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ce0e9c67cfe61c7a91a284331ecc53fa01c32879/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:6
*self.slot = value; } } let mut project = self.project(); let val = project.slot.take(); let prev = project.local.inner.with(|c| c.replace(val)); let _guard = Guard { prev, slot: &mut project.slot, local: *project.local, ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
ce0e9c67cfe61c7a91a284331ecc53fa01c32879
github
async-runtime
https://github.com/tokio-rs/tokio/blob/ce0e9c67cfe61c7a91a284331ecc53fa01c32879/tokio/src/task/task_local.rs
201
242
tokio-rs/tokio:tokio/src/task/task_local.rs:4
{ TaskLocalFuture { local: &self, slot: Some(value), future: f, } .await } /// Accesses the current task-local and runs the provided closure. /// /// # Panics /// /// This function will panic if not called within the context /// of...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
575938d4579e6fe6a89b700aadb0ae2bbab5483b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/575938d4579e6fe6a89b700aadb0ae2bbab5483b/tokio/src/task/task_local.rs
121
180
tokio-rs/tokio:tokio/src/task/task_local.rs:6
*self.slot = value; } } let mut project = self.project(); let val = project.slot.take(); let prev = project.local.inner.with(|c| c.replace(val)); let _guard = Guard { prev, slot: &mut project.slot, local: *project.local, ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
575938d4579e6fe6a89b700aadb0ae2bbab5483b
github
async-runtime
https://github.com/tokio-rs/tokio/blob/575938d4579e6fe6a89b700aadb0ae2bbab5483b/tokio/src/task/task_local.rs
201
241
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro wraps any number of static declar...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
}; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[macro_export] macro_rules! __task_local_inner { ($(#[$attr:meta])* $vis:vis $name:ident, $t:ty) => { $vis static $name: $crate::task::LocalKey<$t> =...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:3
/// }).await; /// /// NUMBER.scope(2, async move { /// assert_eq!(NUMBER.get(), 2); /// /// NUMBER.scope(3, async move { /// assert_eq!(NUMBER.get(), 3); /// }).await; /// }).await; /// # } /// ``` /// [`std::thread::LocalKey`]: struct@std::thread::LocalKey pub struct LocalKey<T: 'static> { #[do...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/task_local.rs
81
140
tokio-rs/tokio:tokio/src/task/task_local.rs:4
local: &self, slot: Some(value), future: f, } .await } /// Accesses the current task-local and runs the provided closure. /// /// # Panics /// /// This function will panic if not called within the context /// of a future containing a task-local with t...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/task_local.rs
121
180
tokio-rs/tokio:tokio/src/task/task_local.rs:5
} impl<T: Copy + 'static> LocalKey<T> { /// Returns a copy of the task-local value /// if the task-local value implements `Copy`. pub fn get(&'static self) -> T { self.with(|v| *v) } } impl<T: 'static> fmt::Debug for LocalKey<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/task_local.rs:6
} let mut project = self.project(); let val = project.slot.take(); let prev = project.local.inner.with(|c| c.replace(val)); let _guard = Guard { prev, slot: &mut project.slot, local: *project.local, }; project.future.poll(cx) } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e70a1b6d64ac2b3943d674d8f3b0b362fdc668b9/tokio/src/task/task_local.rs
201
240
tokio-rs/tokio:tokio/src/task/task_local.rs:2
}; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[macro_export] macro_rules! __task_local_inner { ($(#[$attr:meta])* $vis:vis $name:ident, $t:ty) => { $vis static $name: $crate::task::LocalKey<$t> =...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
43bbbf61a2a87a879834ec644fd4f1c598e77640
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43bbbf61a2a87a879834ec644fd4f1c598e77640/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:3
/// }).await; /// /// NUMBER.scope(2, async move { /// assert_eq!(NUMBER.get(), 2); /// /// NUMBER.scope(3, async move { /// assert_eq!(NUMBER.get(), 3); /// }).await; /// }).await; /// # } /// ``` /// [`std::thread::LocalKey`]: https://doc.rust-lang.org/std/thread/struct.LocalKey.html pub struct Lo...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
43bbbf61a2a87a879834ec644fd4f1c598e77640
github
async-runtime
https://github.com/tokio-rs/tokio/blob/43bbbf61a2a87a879834ec644fd4f1c598e77640/tokio/src/task/task_local.rs
81
140
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro wraps any number of static declar...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
6edc64afc7d9f71d67a3c98fd56f34942f651879
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6edc64afc7d9f71d67a3c98fd56f34942f651879/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declares a new task-local key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro wraps any number of static declar...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
f39c15334e74b07a44efaa0f7201262e17e4f062
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
}; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[macro_export] macro_rules! __task_local_inner { ($(#[$attr:meta])* $vis:vis $name:ident, $t:ty) => { static $name: $crate::task::LocalKey<$t> = { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
f39c15334e74b07a44efaa0f7201262e17e4f062
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f39c15334e74b07a44efaa0f7201262e17e4f062/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:6
} let mut project = self.project(); let val = project.slot.take(); let prev = project.local.inner.with(|c| c.replace(val)); let _guard = Guard { prev, slot: &mut project.slot, local: *project.local, }; project.future.poll(cx) } ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
90969420a2ac1562e3ac523e14bae064e169bf80
github
async-runtime
https://github.com/tokio-rs/tokio/blob/90969420a2ac1562e3ac523e14bae064e169bf80/tokio/src/task/task_local.rs
201
240
tokio-rs/tokio:tokio/src/task/task_local.rs:1
use pin_project_lite::pin_project; use std::cell::RefCell; use std::error::Error; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, thread}; /// Declare a new task local storage key of type [`tokio::task::LocalKey`]. /// /// # Syntax /// /// The macro wraps any number of static...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
619d730d610bbfd0a13285178d6bf3d89a29d6a3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/619d730d610bbfd0a13285178d6bf3d89a29d6a3/tokio/src/task/task_local.rs
1
60
tokio-rs/tokio:tokio/src/task/task_local.rs:2
}; ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty) => { $crate::__task_local_inner!($(#[$attr])* $vis $name, $t); } } #[doc(hidden)] #[macro_export] macro_rules! __task_local_inner { ($(#[$attr:meta])* $vis:vis $name:ident, $t:ty) => { static $name: $crate::task::LocalKey<$t> = { ...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
619d730d610bbfd0a13285178d6bf3d89a29d6a3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/619d730d610bbfd0a13285178d6bf3d89a29d6a3/tokio/src/task/task_local.rs
41
100
tokio-rs/tokio:tokio/src/task/task_local.rs:3
/// } /// /// FOO.scope(1, async move { /// assert_eq!(FOO.get(), 1); /// }).await; /// /// FOO.scope(2, async move { /// assert_eq!(FOO.get(), 2); /// /// FOO.scope(3, async move { /// assert_eq!(FOO.get(), 3); /// }).await; /// }).await; /// # } /// ``` pub struct LocalKey<T: 'static> { #[...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
619d730d610bbfd0a13285178d6bf3d89a29d6a3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/619d730d610bbfd0a13285178d6bf3d89a29d6a3/tokio/src/task/task_local.rs
81
140
tokio-rs/tokio:tokio/src/task/task_local.rs:4
TaskLocalFuture { local: &self, slot: Some(value), future: f, } .await } /// Access this task-local key, running the provided closure with a reference /// passed to the value. /// /// # Panics /// /// This function will panic if not called...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
619d730d610bbfd0a13285178d6bf3d89a29d6a3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/619d730d610bbfd0a13285178d6bf3d89a29d6a3/tokio/src/task/task_local.rs
121
180
tokio-rs/tokio:tokio/src/task/task_local.rs:5
} impl<T: Copy + 'static> LocalKey<T> { /// Get a copy of the task-local value if it implements /// the `Copy` trait. pub fn get(&'static self) -> T { self.with(|v| *v) } } impl<T: 'static> fmt::Debug for LocalKey<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.pa...
rust
rust
macro-heavy
tokio-rs/tokio
tokio/src/task/task_local.rs
MIT
619d730d610bbfd0a13285178d6bf3d89a29d6a3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/619d730d610bbfd0a13285178d6bf3d89a29d6a3/tokio/src/task/task_local.rs
161
220
tokio-rs/tokio:tokio/src/task/tests/loom.rs:1
use crate::task; use crate::tests::loom_schedule::LoomSchedule; use tokio_test::{assert_err, assert_ok}; use loom::future::block_on; use loom::sync::atomic::AtomicBool; use loom::sync::atomic::Ordering::{Acquire, Release}; use loom::thread; use std::future::Future; #[test] fn create_drop_join_handle() { loom::mo...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/loom.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/loom.rs
1
60
tokio-rs/tokio:tokio/src/task/tests/loom.rs:2
let th = thread::spawn(move || { block_on(poll_fn(|cx| { let _ = Pin::new(&mut join_handle).poll(cx); Poll::Ready(()) })); }); assert_none!(task.run(schedule)); th.join().unwrap(); }); } #[test] fn join_output() { loom::model(|| ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/loom.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/loom.rs
41
100
tokio-rs/tokio:tokio/src/task/tests/loom.rs:3
let th = join_one_task(join_handle); work(schedule); assert_ok!(th.join().unwrap()); }); } #[test] fn wake_by_val() { loom::model(|| { let (task, join_handle) = task::joinable(gated(2, true, true)); let schedule = LoomSchedule::new(); let schedule = &schedule; ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/loom.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/loom.rs
81
140
tokio-rs/tokio:tokio/src/task/tests/loom.rs:4
}; assert_none!(task.run(&mut || Some(From::from(&s2)))); assert_none!(s1.recv()); assert_ok!(th.join().unwrap()); }); } #[test] fn shutdown_task_before_poll() { loom::model(|| { let (task, join_handle) = task::joinable::<_, LoomSchedule>(async { "hello" }); let th = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/loom.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/loom.rs
121
180
tokio-rs/tokio:tokio/src/task/tests/loom.rs:5
task.shutdown(); } None => { list.shutdown(); } }; match s1.recv() { Some(task) => task.shutdown(), None => {} } assert_err!(th.join().unwrap()); }); } #[test] fn shutdown_from_queue_after_poll() { loo...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/loom.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/loom.rs
161
220
tokio-rs/tokio:tokio/src/task/tests/loom.rs:6
use std::task::Poll; let gate = Arc::new(AtomicBool::new(false)); let mut fired = false; poll_fn(move |cx| { if !fired { for _ in 0..n { let gate = gate.clone(); let waker = cx.waker().clone(); thread::spawn(move || { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/loom.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/loom.rs
201
260
tokio-rs/tokio:tokio/src/task/tests/loom.rs:7
while let Some(t) = task.take() { task = t.run(&mut || Some(From::from(schedule))); } } } /// Spawn a thread to wait on the join handle. Uses a single task. fn join_one_task<T: Future + 'static>(join_handle: T) -> loom::thread::JoinHandle<T::Output> { thread::spawn(move || block_on(join_han...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/loom.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/loom.rs
241
277
tokio-rs/tokio:tokio/src/task/tests/task.rs:1
use crate::sync::oneshot; use crate::task::{self, Header}; use crate::tests::backoff::*; use crate::tests::mock_schedule::{mock, Mock}; use crate::tests::track_drop::track_drop; use tokio_test::task::spawn; use tokio_test::{assert_pending, assert_ready_err, assert_ready_ok}; use futures::future::poll_fn; use std::syn...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
1
60
tokio-rs/tokio:tokio/src/task/tests/task.rs:2
assert!(did_drop.did_drop_output()); } #[test] fn create_yield_complete_drop() { let (tx, rx) = mpsc::channel(); let (task, did_drop) = track_drop(async move { backoff(1).await; tx.send(1).unwrap(); }); let (task, _) = task::joinable(task); let mock = mock().bind(&task).release_l...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
41
100
tokio-rs/tokio:tokio/src/task/tests/task.rs:3
}); let (task, _) = task::joinable(task); let mock = mock().bind(&task).release_local(); let mock = || Some(From::from(&mock)); // Task is returned let task = assert_some!(task.run(mock)); // The future was **not** dropped. assert!(!did_drop.did_drop_future()); assert_none!(task.run...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
81
140
tokio-rs/tokio:tokio/src/task/tests/task.rs:4
let task = assert_some!(mock.next_pending_run()); assert_none!(task.run(&mut || Some(From::from(&mock)))); // The future was dropped. assert!(did_drop.did_drop_future()); assert!(did_drop.did_drop_output()); } #[test] fn notify_complete() { use std::task::Poll::Ready; let (task, did_drop) = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
121
180
tokio-rs/tokio:tokio/src/task/tests/task.rs:5
let (task, _) = task::joinable(task); let mock1 = mock(); let mock2 = mock().bind(&task).release(); // Task is returned let task = assert_some!(task.run(&mut || Some(From::from(&mock2)))); assert_none!(task.run(&mut || Some(From::from(&mock1)))); // The message was sent assert!(rx.try_re...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
161
220
tokio-rs/tokio:tokio/src/task/tests/task.rs:6
let mut handle = spawn(handle); let mock = mock().bind(&task).release_local(); assert!(task.run(&mut || Some(From::from(&mock))).is_none()); assert!(did_drop.did_drop_future()); assert!(!did_drop.did_drop_output()); assert!(!handle.is_woken()); let out = assert_ready_ok!(handle.poll()); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
201
260
tokio-rs/tokio:tokio/src/task/tests/task.rs:7
assert!(did_drop.did_drop_output()); } #[test] fn join_task_complete_later() { let (task, did_drop) = track_drop(async move { backoff(1).await; "hello".to_string() }); let (task, handle) = task::joinable(task); let mut handle = spawn(async { handle.await }); let mock = mock().bind...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
241
300
tokio-rs/tokio:tokio/src/task/tests/task.rs:8
}); let (task, handle) = task::joinable(task); let mut handle = spawn(async { handle.await }); let mock = mock().bind(&task).release_local(); assert_pending!(handle.poll()); drop(handle); let task = assert_some!(task.run(&mut || Some(From::from(&mock)))); assert!(!did_drop.did_drop_futu...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
281
340
tokio-rs/tokio:tokio/src/task/tests/task.rs:9
let mut t2 = spawn(poll_fn(|cx| Pin::new(&mut handle).poll(cx))); assert_pending!(t2.poll()); assert!(!did_drop.did_drop_future()); assert!(!did_drop.did_drop_output()); assert_none!(task.run(&mut || Some(From::from(&mock)))); assert!(t2.is_woken()); let out = assert_ready_ok!(t2.poll()); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
321
380
tokio-rs/tokio:tokio/src/task/tests/task.rs:10
fn non_initial_task_state_drop_join_handle_without_polling() { let (tx, rx) = oneshot::channel::<()>(); let (task, did_drop) = track_drop(async move { rx.await.unwrap(); "hello".to_string() }); let (task, handle) = task::joinable(task); let mock = mock().bind(&task).schedule().rel...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
361
420
tokio-rs/tokio:tokio/src/task/tests/task.rs:11
let mock = mock().bind(&task).release_local(); assert!(task.run(&mut || Some(From::from(&mock))).is_none()); assert!(did_drop.did_drop_future()); } #[test] #[cfg(not(miri))] fn task_panic_join() { let (task, did_drop) = track_drop(async move { if true { panic!() } "hel...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
401
460
tokio-rs/tokio:tokio/src/task/tests/task.rs:12
let mock1 = mock(); let mock2 = mock().bind(&task).schedule().release(); assert_pending!(handle.poll()); assert_none!(task.run(&mut || Some(From::from(&mock2)))); tx.send("hello").unwrap(); let task = assert_some!(mock2.next_pending_run()); assert_none!(task.run(&mut || Some(From::from(&mock...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
441
500
tokio-rs/tokio:tokio/src/task/tests/task.rs:13
tx.send("hello").unwrap(); let task = assert_some!(mock2.next_pending_run()); assert_none!(task.run(&mut || Some(From::from(&mock1)))); assert!(did_drop.did_drop_future()); // The join handle was notified assert!(handle.is_woken()); // Get the output let out = assert_ready_ok!(handle.poll...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
481
540
tokio-rs/tokio:tokio/src/task/tests/task.rs:14
let task = assert_some!(mock.next_pending_drop()); drop(task); assert_ready_err!(handle.poll()); drop(tx); } #[test] fn shutdown_from_list_after_notified() { let (tx, rx) = oneshot::channel::<()>(); let mut list = task::OwnedList::new(); let (task, did_drop) = track_drop(async move { rx.awai...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
521
580
tokio-rs/tokio:tokio/src/task/tests/task.rs:15
assert_ready_err!(handle.poll()); } #[test] fn shutdown_from_list_after_complete() { let mut list = task::OwnedList::new(); let (task, did_drop) = track_drop(async move { backoff(1).await; "hello" }); let (task, handle) = task::joinable(task); let mut handle = spawn(handle); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
561
620
tokio-rs/tokio:tokio/src/task/tests/task.rs:16
let (task, did_drop) = track_drop(async move { rx.await }); let (task, handle) = task::joinable::<_, Mock>(task); let mut handle = spawn(handle); assert_pending!(handle.poll()); task.shutdown(); assert!(did_drop.did_drop_future()); assert!(handle.is_woken()); assert_ready_err!(handle.pol...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
601
660
tokio-rs/tokio:tokio/src/task/tests/task.rs:17
assert_ready_err!(handle.poll()); } #[test] fn waker_ref_will_wake_clone() { use std::task::Poll::Ready; let (task, handle) = task::joinable(poll_fn(|cx| { let waker = cx.waker().clone(); assert!(cx.waker().will_wake(&waker)); Ready(()) })); let mut handle = spawn(handle); ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/tests/task.rs
641
661
tokio-rs/tokio:tokio/src/task/tests/task.rs:16
let (task, did_drop) = track_drop(async move { rx.await }); let (task, handle) = task::joinable::<_, Mock>(task); let mut handle = spawn(handle); assert_pending!(handle.poll()); task.shutdown(); assert!(did_drop.did_drop_future()); assert!(handle.is_woken()); assert_ready_err!(handle.pol...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
8546ff826db8dba1e39b4119ad909fb6cab2492a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/task/tests/task.rs
601
643
tokio-rs/tokio:tokio/src/task/tests/task.rs:1
use crate::sync::oneshot; use crate::task::{self, Header}; use crate::tests::backoff::*; use crate::tests::mock_schedule::{mock, Mock}; use crate::tests::track_drop::track_drop; use tokio_test::task::spawn; use tokio_test::{assert_pending, assert_ready_err, assert_ready_ok}; use futures::future::poll_fn; use std::syn...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/task.rs
1
60
tokio-rs/tokio:tokio/src/task/tests/task.rs:2
assert!(did_drop.did_drop_output()); } #[test] fn create_yield_complete_drop() { let (tx, rx) = mpsc::channel(); let (task, did_drop) = track_drop(async move { backoff(1).await; tx.send(1).unwrap(); }); let task = task::background(task); let mock = mock().bind(&task).release_loca...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/task.rs
41
100
tokio-rs/tokio:tokio/src/task/tests/task.rs:3
}); let task = task::background(task); let mock = mock().bind(&task).release_local(); let mock = || Some(From::from(&mock)); // Task is returned let task = assert_some!(task.run(mock)); // The future was **not** dropped. assert!(!did_drop.did_drop_future()); assert_none!(task.run(mo...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/task.rs
81
140
tokio-rs/tokio:tokio/src/task/tests/task.rs:4
let task = assert_some!(mock.next_pending_run()); assert_none!(task.run(&mut || Some(From::from(&mock)))); // The future was dropped. assert!(did_drop.did_drop_future()); assert!(did_drop.did_drop_output()); } #[test] fn notify_complete() { use std::task::Poll::Ready; let (task, did_drop) = ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/task.rs
121
180
tokio-rs/tokio:tokio/src/task/tests/task.rs:5
let task = task::background(task); let mock1 = mock(); let mock2 = mock().bind(&task).release(); // Task is returned let task = assert_some!(task.run(&mut || Some(From::from(&mock2)))); assert_none!(task.run(&mut || Some(From::from(&mock1)))); // The message was sent assert!(rx.try_recv(...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/task.rs
161
220
tokio-rs/tokio:tokio/src/task/tests/task.rs:10
fn non_initial_task_state_drop_join_handle_without_polling() { let (tx, rx) = oneshot::channel::<()>(); let (task, did_drop) = track_drop(async move { rx.await.unwrap(); "hello".to_string() }); let (task, handle) = task::joinable(task); let mock = mock().bind(&task).schedule().rel...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/task/tests/task.rs
MIT
8a7e57786a5dca139f5b4261685e22991ded0859
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8a7e57786a5dca139f5b4261685e22991ded0859/tokio/src/task/tests/task.rs
361
420
tokio-rs/tokio:tokio/src/task/unconstrained.rs:1
use pin_project_lite::pin_project; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; pin_project! { /// Future for the [`unconstrained`](unconstrained) method. #[cfg_attr(docsrs, doc(cfg(feature = "rt")))] #[must_use = "Unconstrained does nothing unless polled"] pub struct Unc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/unconstrained.rs
MIT
a051ed726f3b99b077e8c9ef8ef1df2ab2943213
github
async-runtime
https://github.com/tokio-rs/tokio/blob/a051ed726f3b99b077e8c9ef8ef1df2ab2943213/tokio/src/task/unconstrained.rs
1
45
tokio-rs/tokio:tokio/src/task/unconstrained.rs:1
use pin_project_lite::pin_project; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; pin_project! { /// Future for the [`unconstrained`](unconstrained) method. #[cfg_attr(docsrs, doc(cfg(feature = "rt")))] #[must_use = "Unconstrained does nothing unless polled"] pub struct Unc...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/unconstrained.rs
MIT
83243170052afe3b9a40a12ba7d66f09645d3971
github
async-runtime
https://github.com/tokio-rs/tokio/blob/83243170052afe3b9a40a12ba7d66f09645d3971/tokio/src/task/unconstrained.rs
1
45
tokio-rs/tokio:tokio/src/task/unconstrained.rs:1
use pin_project_lite::pin_project; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; pin_project! { /// Future for the [`unconstrained`](unconstrained) method. #[must_use = "Unconstrained does nothing unless polled"] pub struct Unconstrained<F> { #[pin] inner: F, ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/unconstrained.rs
MIT
05eeea570e69f78b5937e807272551bc3075c073
github
async-runtime
https://github.com/tokio-rs/tokio/blob/05eeea570e69f78b5937e807272551bc3075c073/tokio/src/task/unconstrained.rs
1
43
tokio-rs/tokio:tokio/src/task/waker.rs:1
use crate::task::harness::Harness; use crate::task::{Header, Schedule}; use std::future::Future; use std::marker::PhantomData; use std::mem::ManuallyDrop; use std::ops; use std::task::{RawWaker, RawWakerVTable, Waker}; pub(super) struct WakerRef<'a, S: 'static> { waker: ManuallyDrop<Waker>, _p: PhantomData<(&...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/waker.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/waker.rs
1
60
tokio-rs/tokio:tokio/src/task/waker.rs:2
fn deref(&self) -> &Waker { &self.waker } } unsafe fn clone_waker<T, S>(ptr: *const ()) -> RawWaker where T: Future, S: Schedule, { let meta = ptr as *const Header; (*meta).state.ref_inc(); raw_waker::<T, S>(meta) } unsafe fn drop_waker<T, S>(ptr: *const ()) where T: Future, S:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/waker.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/waker.rs
41
97
tokio-rs/tokio:tokio/src/task/waker.rs:3
harness.wake_by_ref(); } fn raw_waker<T, S>(meta: *const Header) -> RawWaker where T: Future, S: Schedule, { let ptr = meta as *const (); let vtable = &RawWakerVTable::new( clone_waker::<T, S>, wake_by_val::<T, S>, wake_by_ref::<T, S>, drop_waker::<T, S>, ); RawW...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/waker.rs
MIT
5930acef736d45733dc182e420a2417a164c71ba
github
async-runtime
https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/waker.rs
81
97
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use crate::runtime::context; use std::future::poll_fn; use std::task::{ready, Poll}; /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that future /// completes (with no output.) The current task will be re-added as a pending /// task at the _back_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/yield_now.rs
1
54
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use crate::runtime::context; use std::future::poll_fn; use std::task::{ready, Poll}; /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that future /// completes (with no output.) The current task will be re-added as a pending /// task at the _back_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
9dacb1c53e341b1183a89800d46ee33c6eabf7ad
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9dacb1c53e341b1183a89800d46ee33c6eabf7ad/tokio/src/task/yield_now.rs
1
54
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use crate::runtime::context; use std::future::Future; use std::pin::Pin; use std::task::{ready, Context, Poll}; /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that future /// completes (with no output.) The current task will be re-added as a pen...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
11f66f43a09169b893212b854c6c49985ff2224f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/task/yield_now.rs
1
60
tokio-rs/tokio:tokio/src/task/yield_now.rs:2
struct YieldNow { yielded: bool, } impl Future for YieldNow { type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { ready!(crate::trace::trace_leaf(cx)); if self.yielded { return Poll::Ready(()); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
11f66f43a09169b893212b854c6c49985ff2224f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/11f66f43a09169b893212b854c6c49985ff2224f/tokio/src/task/yield_now.rs
41
64
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use crate::runtime::context; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that future /// completes (with no output.) The current task will be re-added as a pending //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
6871084629ad95c37c7136d865890ab2e371ea12
github
async-runtime
https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/task/yield_now.rs
1
60
tokio-rs/tokio:tokio/src/task/yield_now.rs:2
struct YieldNow { yielded: bool, } impl Future for YieldNow { type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { ready!(crate::trace::trace_leaf(cx)); if self.yielded { return Poll::Ready(()); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
c748f4965eae883a2291945116d84cab5d657100
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c748f4965eae883a2291945116d84cab5d657100/tokio/src/task/yield_now.rs
41
64
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use crate::runtime::context; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that future /// completes (with no output.) The current task will be re-added as a pending //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
7430865d655d31836ce62e65d8f03bcb9a85b12e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7430865d655d31836ce62e65d8f03bcb9a85b12e/tokio/src/task/yield_now.rs
1
60
tokio-rs/tokio:tokio/src/task/yield_now.rs:2
struct YieldNow { yielded: bool, } impl Future for YieldNow { type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { ready!(crate::trace::trace_leaf(cx)); if self.yielded { return Poll::Ready(()); } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
7430865d655d31836ce62e65d8f03bcb9a85b12e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7430865d655d31836ce62e65d8f03bcb9a85b12e/tokio/src/task/yield_now.rs
41
72
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use crate::runtime::context; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that future /// completes (with no output.) The current task will be re-added as a pending //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f/tokio/src/task/yield_now.rs
1
60
tokio-rs/tokio:tokio/src/task/yield_now.rs:2
struct YieldNow { yielded: bool, } impl Future for YieldNow { type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { #[cfg(all( tokio_unstable, tokio_taskdump, feature = "rt", t...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/660eac71f0ac7274dc3ba6dd92df9ff2ea61be9f/tokio/src/task/yield_now.rs
41
79
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use crate::runtime::context; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that future /// completes (with no output.) The current task will be re-added as a pending //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
22862739dddd49a94065aa7a917cde2dc8a3f6bc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22862739dddd49a94065aa7a917cde2dc8a3f6bc/tokio/src/task/yield_now.rs
1
60
tokio-rs/tokio:tokio/src/task/yield_now.rs:2
struct YieldNow { yielded: bool, } impl Future for YieldNow { type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { if self.yielded { return Poll::Ready(()); } self.yielded = true; let d...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
22862739dddd49a94065aa7a917cde2dc8a3f6bc
github
async-runtime
https://github.com/tokio-rs/tokio/blob/22862739dddd49a94065aa7a917cde2dc8a3f6bc/tokio/src/task/yield_now.rs
41
70
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that future /// completes (with no output.) The current task will be re-added as a pending /// task at the _back_ of the pe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
fe770dc509b19c5159ece7e38f353c5e30df3d6c
github
async-runtime
https://github.com/tokio-rs/tokio/blob/fe770dc509b19c5159ece7e38f353c5e30df3d6c/tokio/src/task/yield_now.rs
1
58
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that future /// completes (with no output.) The current task will be re-added as a pending /// task at the _back_ of the pe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
7e51b44a209dab1de0810d90e3dddff80c2e44a6
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7e51b44a209dab1de0810d90e3dddff80c2e44a6/tokio/src/task/yield_now.rs
1
59
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; cfg_rt! { /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that /// future completes (with no output.) The current task will be re-added as /// a pendin...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
c90681bd8e629b5fde988b9f5be7b915e5cf8ae5
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/task/yield_now.rs
1
38
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; cfg_rt_util! { /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that /// future completes (with no output.) The current task will be re-added as /// a p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
8880222036f37c6204c8466f25e828447f16dacb
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/task/yield_now.rs
1
38
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; doc_rt_core! { /// Yields execution back to the Tokio runtime. /// /// A task yields by awaiting on `yield_now()`, and may resume when that /// future completes (with no output.) The current task will be re-added as /// a p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
f9ddb93604a830d106475bd4c4cae436fafcc0da
github
async-runtime
https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/yield_now.rs
1
38
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; doc_rt_core! { /// Return a `Future` that can be `await`-ed to yield execution back to the /// Tokio runtime. /// /// A task yields by awaiting the returned `Future`, and may resume when /// that future completes (with no o...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
bb6c3839ef0491310f40e4570b465bcc6b09ae95
github
async-runtime
https://github.com/tokio-rs/tokio/blob/bb6c3839ef0491310f40e4570b465bcc6b09ae95/tokio/src/task/yield_now.rs
1
39
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; doc_rt_core! { /// Yield execution back to the Tokio runtime. pub async fn yield_now() { /// Yield implementation struct YieldNow { yielded: bool, } impl Future for YieldNow { ty...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
8b60c5386a60be4dacffe71823350040e8ba90fd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8b60c5386a60be4dacffe71823350040e8ba90fd/tokio/src/task/yield_now.rs
1
29
tokio-rs/tokio:tokio/src/task/yield_now.rs:1
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; /// Yield execution back to the Tokio runtime. pub async fn yield_now() { /// Yield implementation struct YieldNow { yielded: bool, } impl Future for YieldNow { type Output = (); fn poll(mut self: Pin<...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/task/yield_now.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/task/yield_now.rs
1
27
tokio-rs/tokio:tokio/src/tests/loom_schedule.rs:1
use crate::task::{Schedule, ScheduleSendOnly, Task}; use loom::sync::Notify; use std::collections::VecDeque; use std::sync::Mutex; pub(crate) struct LoomSchedule { notify: Notify, pending: Mutex<VecDeque<Option<Task<Self>>>>, } impl LoomSchedule { pub(crate) fn new() -> LoomSchedule { LoomSchedul...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/tests/loom_schedule.rs
MIT
38e602f4d812c196d5dc0bc245e79ccad4e77cfd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38e602f4d812c196d5dc0bc245e79ccad4e77cfd/tokio/src/tests/loom_schedule.rs
1
53
tokio-rs/tokio:tokio/src/tests/mock_schedule.rs:1
#![allow(warnings)] use crate::task::{Header, Schedule, ScheduleSendOnly, Task}; use std::collections::VecDeque; use std::sync::Mutex; use std::thread; pub(crate) struct Mock { inner: Mutex<Inner>, } pub(crate) struct Noop; pub(crate) static NOOP_SCHEDULE: Noop = Noop; struct Inner { calls: VecDeque<Call>, ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/tests/mock_schedule.rs
MIT
38e602f4d812c196d5dc0bc245e79ccad4e77cfd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38e602f4d812c196d5dc0bc245e79ccad4e77cfd/tokio/src/tests/mock_schedule.rs
1
60
tokio-rs/tokio:tokio/src/tests/mock_schedule.rs:2
impl Mock { pub(crate) fn bind(self, task: &Task<Mock>) -> Self { self.push(Call::Bind(task.header() as *const _)); self } pub(crate) fn release(self) -> Self { self.push(Call::Release); self } pub(crate) fn release_local(self) -> Self { self.push(Call::Rele...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/tests/mock_schedule.rs
MIT
38e602f4d812c196d5dc0bc245e79ccad4e77cfd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38e602f4d812c196d5dc0bc245e79ccad4e77cfd/tokio/src/tests/mock_schedule.rs
41
100
tokio-rs/tokio:tokio/src/tests/mock_schedule.rs:3
.expect(&format!("received `{}`, but none expected", name)) } } impl Schedule for Mock { fn bind(&self, task: &Task<Self>) { match self.next("bind") { Call::Bind(ptr) => { assert!(ptr.eq(&(task.header() as *const _))); } call => panic!("expected `Bind...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/tests/mock_schedule.rs
MIT
38e602f4d812c196d5dc0bc245e79ccad4e77cfd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38e602f4d812c196d5dc0bc245e79ccad4e77cfd/tokio/src/tests/mock_schedule.rs
81
134
tokio-rs/tokio:tokio/src/tests/mock_schedule.rs:4
} } impl Schedule for Noop { fn bind(&self, _task: &Task<Self>) {} fn release(&self, _task: Task<Self>) {} fn release_local(&self, _task: &Task<Self>) {} fn schedule(&self, _task: Task<Self>) {} } impl ScheduleSendOnly for Noop {}
rust
rust
testsuite
tokio-rs/tokio
tokio/src/tests/mock_schedule.rs
MIT
38e602f4d812c196d5dc0bc245e79ccad4e77cfd
github
async-runtime
https://github.com/tokio-rs/tokio/blob/38e602f4d812c196d5dc0bc245e79ccad4e77cfd/tokio/src/tests/mock_schedule.rs
121
134
tokio-rs/tokio:tokio/src/tests/mod.rs:1
#[cfg(not(loom))] pub(crate) mod backoff; #[cfg(loom)] pub(crate) mod loom_schedule; pub(crate) mod mock_schedule; #[cfg(not(loom))] pub(crate) mod track_drop;
rust
rust
testsuite
tokio-rs/tokio
tokio/src/tests/mod.rs
MIT
0d38936b35779b604770120da2e98560bbb6241f
github
async-runtime
https://github.com/tokio-rs/tokio/blob/0d38936b35779b604770120da2e98560bbb6241f/tokio/src/tests/mod.rs
1
10
tokio-rs/tokio:tokio/src/tests/mod.rs:1
#[macro_export] /// Assert option is some macro_rules! assert_some { ($e:expr) => {{ match $e { Some(v) => v, _ => panic!("expected some, was none"), } }}; } #[macro_export] /// Assert option is none macro_rules! assert_none { ($e:expr) => {{ match $e { ...
rust
rust
testsuite
tokio-rs/tokio
tokio/src/tests/mod.rs
MIT
27e5b41067d01c0c9fac230c5addb58034201a63
github
async-runtime
https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/tests/mod.rs
1
32
tokio-rs/tokio:tokio/src/time/clock.rs:1
#![cfg_attr(not(feature = "rt"), allow(dead_code))] //! Source of time abstraction. //! //! By default, `std::time::Instant::now()` is used. However, when the //! `test-util` feature flag is enabled, the values returned for `now()` are //! configurable. cfg_not_test_util! { use crate::time::{Instant}; #[deri...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/clock.rs
1
60
tokio-rs/tokio:tokio/src/time/clock.rs:2
let res = match Handle::try_current() { Ok(handle) => f(Some(handle.inner.driver().clock())), Err(ref e) if e.is_missing_context() => f(None), Err(_) => panic!("{}", crate::util::error::THREAD_LOCAL_DESTROYED_ERROR), }; match res { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/clock.rs
41
100
tokio-rs/tokio:tokio/src/time/clock.rs:5
pub fn pause() { with_clock(|maybe_clock| { match maybe_clock { Some(clock) => clock.pause(), None => Err("time cannot be frozen from outside the Tokio runtime"), } }); } /// Resumes time. /// /// Clears the saved `Instant::now()` ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/clock.rs
161
220
tokio-rs/tokio:tokio/src/time/clock.rs:7
/// // Use sleep with auto-advance for reliable timeout testing /// time::sleep(Duration::from_secs(5)).await; /// // All timers that were scheduled to fire within 5 seconds /// // have now been processed in order /// } /// ``` /// /// # Panics /// /// Panics if any o...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/clock.rs
241
300
tokio-rs/tokio:tokio/src/time/clock.rs:8
} /// Returns the current instant, factoring in frozen time. pub(crate) fn now() -> Instant { if !DID_PAUSE_CLOCK.load(Ordering::Acquire) { return Instant::from_std(std::time::Instant::now()); } with_clock(|maybe_clock| { Ok(if let Some(clock) = maybe_clock { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/clock.rs
281
340
tokio-rs/tokio:tokio/src/time/clock.rs:9
pub(crate) fn pause(&self) -> Result<(), &'static str> { let mut inner = self.inner.lock(); if !inner.enable_pausing { return Err("`time::pause()` requires the `current_thread` Tokio runtime. \ This is the default Runtime used by `#[tokio::test]."); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/clock.rs
321
380
tokio-rs/tokio:tokio/src/time/clock.rs:10
if inner.unfrozen.is_some() { return Err("time is not frozen"); } inner.base += duration; Ok(()) } pub(crate) fn now(&self) -> Instant { let inner = self.inner.lock(); let mut ret = inner.base; if let Some(unfroz...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/time/clock.rs
361
382
tokio-rs/tokio:tokio/src/time/clock.rs:3
/// True if the ability to pause time is enabled. enable_pausing: bool, /// Instant to use as the clock's base instant. base: std::time::Instant, /// Instant at which the clock was last unfrozen. unfrozen: Option<std::time::Instant>, /// Number of `inhibit_auto_advance...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
013f323def73f85185e2633f1b5f8939cc841318
github
async-runtime
https://github.com/tokio-rs/tokio/blob/013f323def73f85185e2633f1b5f8939cc841318/tokio/src/time/clock.rs
81
140
tokio-rs/tokio:tokio/src/time/clock.rs:4
/// /// If time is paused and the runtime has no work to do, the clock is /// auto-advanced to the next pending timer. This means that [`Sleep`] or /// other timer-backed primitives can cause the runtime to advance the /// current time when awaited. /// /// [`Sleep`]: crate::time::Sleep /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
013f323def73f85185e2633f1b5f8939cc841318
github
async-runtime
https://github.com/tokio-rs/tokio/blob/013f323def73f85185e2633f1b5f8939cc841318/tokio/src/time/clock.rs
121
180
tokio-rs/tokio:tokio/src/time/clock.rs:5
inner.unfrozen = Some(std::time::Instant::now()); Ok(()) }); } /// Advances time. /// /// Increments the saved `Instant::now()` value by `duration`. Subsequent /// calls to `Instant::now()` will return the result of the increment. /// /// This function will make the curr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
013f323def73f85185e2633f1b5f8939cc841318
github
async-runtime
https://github.com/tokio-rs/tokio/blob/013f323def73f85185e2633f1b5f8939cc841318/tokio/src/time/clock.rs
161
220
tokio-rs/tokio:tokio/src/time/clock.rs:6
/// # Auto-advance /// /// If the time is paused and there is no work to do, the runtime advances /// time to the next timer. See [`pause`](pause#auto-advance) for more /// details. /// /// [`sleep`]: fn@crate::time::sleep pub async fn advance(duration: Duration) { with_clock(|maybe_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
013f323def73f85185e2633f1b5f8939cc841318
github
async-runtime
https://github.com/tokio-rs/tokio/blob/013f323def73f85185e2633f1b5f8939cc841318/tokio/src/time/clock.rs
201
260
tokio-rs/tokio:tokio/src/time/clock.rs:7
let clock = Clock { inner: Mutex::new(Inner { enable_pausing, base: now, unfrozen: Some(now), auto_advance_inhibit_count: 0, }), }; if start_paused { if let Err(msg) =...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/time/clock.rs
MIT
013f323def73f85185e2633f1b5f8939cc841318
github
async-runtime
https://github.com/tokio-rs/tokio/blob/013f323def73f85185e2633f1b5f8939cc841318/tokio/src/time/clock.rs
241
300