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/task/error.rs:1 | use std::any::Any;
use std::fmt;
use std::io;
use crate::util::SyncWrapper;
cfg_rt! {
/// Task failed to execute to completion.
pub struct JoinError {
repr: Repr,
}
}
enum Repr {
Cancelled,
Panic(SyncWrapper<Box<dyn Any + Send + 'static>>),
}
impl JoinError {
pub(crate) fn cancelled(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/error.rs | MIT | aef2d64b0a519ff6726f8c139ee1d3e6b1959b0b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/aef2d64b0a519ff6726f8c139ee1d3e6b1959b0b/tokio/src/runtime/task/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/error.rs:1 | use std::any::Any;
use std::fmt;
use std::io;
use std::sync::Mutex;
cfg_rt! {
/// Task failed to execute to completion.
pub struct JoinError {
repr: Repr,
}
}
enum Repr {
Cancelled,
Panic(Mutex<Box<dyn Any + Send + 'static>>),
}
impl JoinError {
pub(crate) fn cancelled() -> JoinError ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/error.rs | MIT | c90681bd8e629b5fde988b9f5be7b915e5cf8ae5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/runtime/task/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/error.rs:3 | pub fn into_panic(self) -> Box<dyn Any + Send + 'static> {
self.try_into_panic()
.expect("`JoinError` reason is not a panic.")
}
/// Consumes the join error, returning the object with which the task
/// panicked if the task terminated due to a panic. Otherwise, `self` is
/// returne... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/error.rs | MIT | c90681bd8e629b5fde988b9f5be7b915e5cf8ae5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/runtime/task/error.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/error.rs:4 | }
}
impl fmt::Debug for JoinError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.repr {
Repr::Cancelled => write!(fmt, "JoinError::Cancelled"),
Repr::Panic(_) => write!(fmt, "JoinError::Panic(...)"),
}
}
}
impl std::error::Error for JoinError... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/error.rs | MIT | c90681bd8e629b5fde988b9f5be7b915e5cf8ae5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c90681bd8e629b5fde988b9f5be7b915e5cf8ae5/tokio/src/runtime/task/error.rs | 121 | 145 |
tokio-rs/tokio:tokio/src/runtime/task/error.rs:1 | use std::any::Any;
use std::fmt;
use std::io;
use std::sync::Mutex;
cfg_task! {
/// Task failed to execute to completion.
pub struct JoinError {
repr: Repr,
}
}
enum Repr {
Cancelled,
Panic(Mutex<Box<dyn Any + Send + 'static>>),
}
impl JoinError {
pub(crate) fn cancelled() -> JoinErro... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/error.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/task/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/error.rs:1 | use std::any::Any;
use std::fmt;
use std::io;
use std::sync::Mutex;
doc_rt_core! {
/// Task failed to execute to completion.
pub struct JoinError {
repr: Repr,
}
}
enum Repr {
Cancelled,
Panic(Mutex<Box<dyn Any + Send + 'static>>),
}
impl JoinError {
pub(crate) fn cancelled() -> JoinE... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/error.rs | MIT | b704c53b9cc76eaf8c9c6585f8444c4515d27728 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b704c53b9cc76eaf8c9c6585f8444c4515d27728/tokio/src/runtime/task/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/error.rs:1 | use std::any::Any;
use std::fmt;
use std::io;
use std::sync::Mutex;
doc_rt_core! {
/// Task failed to execute to completion.
pub struct JoinError {
repr: Repr,
}
}
enum Repr {
Cancelled,
Panic(Mutex<Box<dyn Any + Send + 'static>>),
}
impl JoinError {
pub(crate) fn cancelled() -> JoinE... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/error.rs | MIT | 13de30c53eb90a5453f1cecf47b188e254a293ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/13de30c53eb90a5453f1cecf47b188e254a293ac/tokio/src/runtime/task/error.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/error.rs:3 | /// if err.is_panic() {
/// // Resume the panic on the main task
/// panic::resume_unwind(err.into_panic());
/// }
/// }
/// ```
pub fn into_panic(self) -> Box<dyn Any + Send + 'static> {
self.try_into_panic()
.expect("`JoinError` reason is not a panic... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/error.rs | MIT | 13de30c53eb90a5453f1cecf47b188e254a293ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/13de30c53eb90a5453f1cecf47b188e254a293ac/tokio/src/runtime/task/error.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/error.rs:4 | impl fmt::Display for JoinError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.repr {
Repr::Cancelled => write!(fmt, "cancelled"),
Repr::Panic(_) => write!(fmt, "panic"),
}
}
}
impl fmt::Debug for JoinError {
fn fmt(&self, fmt: &mut fmt::F... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/error.rs | MIT | 13de30c53eb90a5453f1cecf47b188e254a293ac | github | async-runtime | https://github.com/tokio-rs/tokio/blob/13de30c53eb90a5453f1cecf47b188e254a293ac/tokio/src/runtime/task/error.rs | 121 | 151 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:1 | use crate::future::Future;
use crate::runtime::task::core::{Cell, Core, Header, Trailer};
use crate::runtime::task::state::{Snapshot, State};
use crate::runtime::task::waker::waker_ref;
use crate::runtime::task::{Id, JoinError, Notified, RawTask, Schedule, Task};
#[cfg(tokio_unstable)]
use crate::runtime::TaskMeta;
us... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:2 | &self.header().state
}
fn trailer(&self) -> &Trailer {
unsafe { &self.cell.as_ref().trailer }
}
fn core(&self) -> &Core<T, S> {
unsafe { &self.cell.as_ref().core }
}
}
/// Task operations that can be implemented without being generic over the
/// scheduler or task. Only one versio... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:3 | // Now that we have completed the call to schedule, we can
// release our ref-count.
self.drop_reference();
}
TransitionToNotifiedByVal::Dealloc => {
self.dealloc();
}
TransitionToNotifiedByVal::DoNothing => {}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:4 | // a Notified and pass to the task.
//
// Since the caller holds a ref-count, the task cannot be destroyed
// before the call to `schedule` returns even if the call drops the
// `Notified` internally.
self.schedule();
}
}
/// Try to set the wa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:5 | .yield_now(Notified(self.get_new_task()));
// The remaining ref-count is now dropped. We kept the extra
// ref-count until now to ensure that even if the `yield_now`
// call drops the provided task, the task isn't deallocated
// before after `yield_now` r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:6 | TransitionToIdle::Ok => PollFuture::Done,
TransitionToIdle::OkNotified => PollFuture::Notified,
TransitionToIdle::OkDealloc => PollFuture::Dealloc,
TransitionToIdle::Cancelled => PollFuture::Complete,
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:7 | if !self.state().transition_to_shutdown() {
// The task is concurrently running. No further work needed.
self.drop_reference();
return;
}
// By transitioning the lifecycle to `Running`, we have permission to
// drop the future.
cancel_task(self.core()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:8 | pub(super) fn try_read_output(self, dst: &mut Poll<super::Result<T::Output>>, waker: &Waker) {
if can_read_output(self.header(), self.trailer(), waker) {
*dst = Poll::Ready(self.core().take_output());
}
}
pub(super) fn drop_join_handle_slow(self) {
// Try to unset `JOIN_INTE... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:9 | unsafe { self.trailer().set_waker(None) };
}
// Drop the `JoinHandle` reference, possibly deallocating the task
self.drop_reference();
}
// ====== internal ======
/// Completes the task. This method assumes that the state is RUNNING.
fn complete(self) {
// The future h... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:10 | // we have exclusive access to the waker.
unsafe { self.trailer().set_waker(None) };
}
}
}));
// We catch panics here in case invoking a hook panics.
//
// We call this in a separate block so that it runs after the task appears to have
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:11 | 1
}
}
/// Creates a new task that holds its own ref-count.
///
/// # Safety
///
/// Any use of `self` after this call must ensure that a ref-count to the
/// task holds the task alive until after the use of `self`. Passing the
/// returned Task to any method on `self` is unsound... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:12 | // Otherwise swap the stored waker with the provided waker by
// following the rule 5 in task/mod.rs.
header
.state
.unset_waker()
.and_then(|snapshot| set_join_waker(header, trailer, waker.clone(), snapshot))
} else {
// If JOI... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:13 | // If the state could not be updated, then clear the join waker
if res.is_err() {
unsafe {
trailer.set_waker(None);
}
}
res
}
enum PollFuture {
Complete,
Notified,
Done,
Dealloc,
}
/// Cancels the task and store the appropriate error in the stage field.
fn canc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:14 | fn poll_future<T: Future, S: Schedule>(core: &Core<T, S>, cx: Context<'_>) -> Poll<()> {
// Poll the future.
let output = panic::catch_unwind(panic::AssertUnwindSafe(|| {
struct Guard<'a, T: Future, S: Schedule> {
core: &'a Core<T, S>,
}
impl<'a, T: Future, S: Schedule> Drop ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/task/harness.rs | 521 | 567 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:9 | unsafe { self.trailer().set_waker(None) };
}
// Drop the `JoinHandle` reference, possibly deallocating the task
self.drop_reference();
}
// ====== internal ======
/// Completes the task. This method assumes that the state is RUNNING.
fn complete(self) {
// The future h... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/task/harness.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:10 | // we have exclusive access to the waker.
unsafe { self.trailer().set_waker(None) };
}
}
}));
// We catch panics here in case invoking a hook panics.
//
// We call this in a separate block so that it runs after the task appears to have
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3e890cc0171ddb210acdcfec831b7c7bcbb0d2d9/tokio/src/runtime/task/harness.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:1 | use crate::future::Future;
use crate::runtime::task::core::{Cell, Core, Header, Trailer};
use crate::runtime::task::state::{Snapshot, State};
use crate::runtime::task::waker::waker_ref;
use crate::runtime::task::{Id, JoinError, Notified, RawTask, Schedule, Task};
use crate::runtime::TaskMeta;
use std::any::Any;
use st... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:2 | }
fn trailer(&self) -> &Trailer {
unsafe { &self.cell.as_ref().trailer }
}
fn core(&self) -> &Core<T, S> {
unsafe { &self.cell.as_ref().core }
}
}
/// Task operations that can be implemented without being generic over the
/// scheduler or task. Only one version of these methods should... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:3 | // Now that we have completed the call to schedule, we can
// release our ref-count.
self.drop_reference();
}
TransitionToNotifiedByVal::Dealloc => {
self.dealloc();
}
TransitionToNotifiedByVal::DoNothing => {}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:4 | //
// Since the caller holds a ref-count, the task cannot be destroyed
// before the call to `schedule` returns even if the call drops the
// `Notified` internally.
self.schedule();
}
}
/// Try to set the waker notified when the task is complete. Returns ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:5 | // The remaining ref-count is now dropped. We kept the extra
// ref-count until now to ensure that even if the `yield_now`
// call drops the provided task, the task isn't deallocated
// before after `yield_now` returns.
self.drop_reference();
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:6 | TransitionToIdle::OkNotified => PollFuture::Notified,
TransitionToIdle::OkDealloc => PollFuture::Dealloc,
TransitionToIdle::Cancelled => PollFuture::Complete,
}
}
let header_ptr = self.header_ptr();
let w... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:7 | // The task is concurrently running. No further work needed.
self.drop_reference();
return;
}
// By transitioning the lifecycle to `Running`, we have permission to
// drop the future.
cancel_task(self.core());
self.complete();
}
pub(super) fn dea... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:8 | if can_read_output(self.header(), self.trailer(), waker) {
*dst = Poll::Ready(self.core().take_output());
}
}
pub(super) fn drop_join_handle_slow(self) {
// Try to unset `JOIN_INTEREST` and `JOIN_WAKER`. This must be done as a first step in
// case the task concurrently comp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:9 | }
// Drop the `JoinHandle` reference, possibly deallocating the task
self.drop_reference();
}
// ====== internal ======
/// Completes the task. This method assumes that the state is RUNNING.
fn complete(self) {
// The future has completed and its output has been written to the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:10 | unsafe { self.trailer().set_waker(None) };
}
}
}));
// We catch panics here in case invoking a hook panics.
//
// We call this in a separate block so that it runs after the task appears to have
// completed and will still run if the destructor panics.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:11 | /// Creates a new task that holds its own ref-count.
///
/// # Safety
///
/// Any use of `self` after this call must ensure that a ref-count to the
/// task holds the task alive until after the use of `self`. Passing the
/// returned Task to any method on `self` is unsound if dropping the Task
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:12 | .state
.unset_waker()
.and_then(|snapshot| set_join_waker(header, trailer, waker.clone(), snapshot))
} else {
// If JOIN_WAKER is unset, then JoinHandle has mutable access to the
// waker field per rule 2 in task/mod.rs; therefore, skip step (i)
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:13 | unsafe {
trailer.set_waker(None);
}
}
res
}
enum PollFuture {
Complete,
Notified,
Done,
Dealloc,
}
/// Cancels the task and store the appropriate error in the stage field.
fn cancel_task<T: Future, S: Schedule>(core: &Core<T, S>) {
// Drop the future from a panic guard... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:14 | struct Guard<'a, T: Future, S: Schedule> {
core: &'a Core<T, S>,
}
impl<'a, T: Future, S: Schedule> Drop for Guard<'a, T, S> {
fn drop(&mut self) {
// If the future panics on poll, we drop it inside the panic
// guard.
self.core.dro... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 970d880ceb473b222a9ddd4b35b934ca68cecb4a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/970d880ceb473b222a9ddd4b35b934ca68cecb4a/tokio/src/runtime/task/harness.rs | 521 | 564 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:7 | // The task is concurrently running. No further work needed.
self.drop_reference();
return;
}
// By transitioning the lifecycle to `Running`, we have permission to
// drop the future.
cancel_task(self.core());
self.complete();
}
pub(super) fn dea... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/task/harness.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:8 | if can_read_output(self.header(), self.trailer(), waker) {
*dst = Poll::Ready(self.core().take_output());
}
}
pub(super) fn drop_join_handle_slow(self) {
// Try to unset `JOIN_INTEREST`. This must be done as a first step in
// case the task concurrently completed.
if... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/task/harness.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:9 | // The `JoinHandle` is not interested in the output of
// this task. It is our responsibility to drop the
// output.
self.core().drop_future_or_output();
} else if snapshot.is_join_waker_set() {
// Notify the waker. Reading the waker field is s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/task/harness.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:10 | if let Some(task) = self.core().scheduler.release(&me) {
mem::forget(task);
2
} else {
1
}
}
/// Creates a new task that holds its own ref-count.
///
/// # Safety
///
/// Any use of `self` after this call must ensure that a ref-count to the
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/task/harness.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:11 | if unsafe { trailer.will_wake(waker) } {
return false;
}
// Otherwise swap the stored waker with the provided waker by
// following the rule 5 in task/mod.rs.
header
.state
.unset_waker()
.and_then(|snapshot... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/task/harness.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:12 | }
// Update the `JoinWaker` state accordingly
let res = header.state.set_join_waker();
// If the state could not be updated, then clear the join waker
if res.is_err() {
unsafe {
trailer.set_waker(None);
}
}
res
}
enum PollFuture {
Complete,
Notified,
D... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:13 | }
/// Polls the future. If the future completes, the output is written to the
/// stage field.
fn poll_future<T: Future, S: Schedule>(core: &Core<T, S>, cx: Context<'_>) -> Poll<()> {
// Poll the future.
let output = panic::catch_unwind(panic::AssertUnwindSafe(|| {
struct Guard<'a, T: Future, S: Schedu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/task/harness.rs | 481 | 531 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:14 | }
#[cold]
fn panic_to_error<S: Schedule>(
scheduler: &S,
task_id: Id,
panic: Box<dyn Any + Send + 'static>,
) -> JoinError {
scheduler.unhandled_panic();
JoinError::panic(task_id, panic)
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 5ada5114df1e36de2b748e3ea26a196a0e097f47 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5ada5114df1e36de2b748e3ea26a196a0e097f47/tokio/src/runtime/task/harness.rs | 521 | 531 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:8 | if can_read_output(self.header(), self.trailer(), waker) {
*dst = Poll::Ready(self.core().take_output());
}
}
pub(super) fn drop_join_handle_slow(self) {
// Try to unset `JOIN_INTEREST`. This must be done as a first step in
// case the task concurrently completed.
if... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/task/harness.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:9 | // The `JoinHandle` is not interested in the output of
// this task. It is our responsibility to drop the
// output.
self.core().drop_future_or_output();
} else if snapshot.is_join_waker_set() {
// Notify the waker. Reading the waker field is s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/task/harness.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:10 | if let Some(task) = self.core().scheduler.release(&me) {
mem::forget(task);
2
} else {
1
}
}
/// Creates a new task that holds its own ref-count.
///
/// # Safety
///
/// Any use of `self` after this call must ensure that a ref-count to the
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/task/harness.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:11 | // the waker field below is safe per rule 3 in task/mod.rs.)
if unsafe { trailer.will_wake(waker) } {
return false;
}
// Otherwise swap the stored waker with the provided waker by
// following the rule 5 in task/mod.rs.
header
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/task/harness.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:12 | trailer.set_waker(Some(waker));
}
// Update the `JoinWaker` state accordingly
let res = header.state.set_join_waker();
// If the state could not be updated, then clear the join waker
if res.is_err() {
unsafe {
trailer.set_waker(None);
}
}
res
}
enum PollFuture... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:13 | }
}
/// Polls the future. If the future completes, the output is written to the
/// stage field.
fn poll_future<T: Future, S: Schedule>(core: &Core<T, S>, cx: Context<'_>) -> Poll<()> {
// Poll the future.
let output = panic::catch_unwind(panic::AssertUnwindSafe(|| {
struct Guard<'a, T: Future, S: Sche... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/task/harness.rs | 481 | 532 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:14 | Poll::Ready(())
}
#[cold]
fn panic_to_error<S: Schedule>(
scheduler: &S,
task_id: Id,
panic: Box<dyn Any + Send + 'static>,
) -> JoinError {
scheduler.unhandled_panic();
JoinError::panic(task_id, panic)
} | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | b37f0de28a17ced6a9e6738062770d6fea8c5364 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b37f0de28a17ced6a9e6738062770d6fea8c5364/tokio/src/runtime/task/harness.rs | 521 | 532 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:1 | use crate::future::Future;
use crate::runtime::task::core::{Cell, Core, Header, Trailer};
use crate::runtime::task::state::{Snapshot, State};
use crate::runtime::task::waker::waker_ref;
use crate::runtime::task::{Id, JoinError, Notified, RawTask, Schedule, Task};
use std::any::Any;
use std::mem;
use std::mem::Manually... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:2 | fn trailer(&self) -> &Trailer {
unsafe { &self.cell.as_ref().trailer }
}
fn core(&self) -> &Core<T, S> {
unsafe { &self.cell.as_ref().core }
}
}
/// Task operations that can be implemented without being generic over the
/// scheduler or task. Only one version of these methods should exist ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:3 | // release our ref-count.
self.drop_reference();
}
TransitionToNotifiedByVal::Dealloc => {
self.dealloc();
}
TransitionToNotifiedByVal::DoNothing => {}
}
}
/// This call notifies the task. It will not consume any ref-counts... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:4 | // Since the caller holds a ref-count, the task cannot be destroyed
// before the call to `schedule` returns even if the call drops the
// `Notified` internally.
self.schedule();
}
}
/// Try to set the waker notified when the task is complete. Returns true if
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:5 | // The remaining ref-count is now dropped. We kept the extra
// ref-count until now to ensure that even if the `yield_now`
// call drops the provided task, the task isn't deallocated
// before after `yield_now` returns.
self.drop_reference();
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:6 | TransitionToIdle::OkDealloc => PollFuture::Dealloc,
TransitionToIdle::Cancelled => PollFuture::Complete,
}
}
let header_ptr = self.header_ptr();
let waker_ref = waker_ref::<S>(&header_ptr);
let cx = Context::from... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:7 | self.drop_reference();
return;
}
// By transitioning the lifecycle to `Running`, we have permission to
// drop the future.
cancel_task(self.core());
self.complete();
}
pub(super) fn dealloc(self) {
// Observe that we expect to have mutable access to ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:8 | *dst = Poll::Ready(self.core().take_output());
}
}
pub(super) fn drop_join_handle_slow(self) {
// Try to unset `JOIN_INTEREST`. This must be done as a first step in
// case the task concurrently completed.
if self.state().unset_join_interested().is_err() {
// It is o... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:9 | // this task. It is our responsibility to drop the
// output.
self.core().drop_future_or_output();
} else if snapshot.is_join_waker_set() {
// Notify the waker. Reading the waker field is safe per rule 4
// in task/mod.rs, since the JOIN_WAKER ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:10 | /// returned Task to any method on `self` is unsound if dropping the Task
/// could drop `self` before the call on `self` returned.
fn get_new_task(&self) -> Task<S> {
// safety: The header is at the beginning of the cell, so this cast is
// safe.
unsafe { Task::from_raw(self.cell.cast()... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:11 | set_join_waker(header, trailer, waker.clone(), snapshot)
};
match res {
Ok(_) => return false,
Err(snapshot) => {
assert!(snapshot.is_complete());
}
}
}
true
}
fn set_join_waker(
header: &Header,
trailer: &Trailer,
waker: ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:12 | enum PollFuture {
Complete,
Notified,
Done,
Dealloc,
}
/// Cancels the task and store the appropriate error in the stage field.
fn cancel_task<T: Future, S: Schedule>(core: &Core<T, S>) {
// Drop the future from a panic guard.
let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:13 | self.core.drop_future_or_output();
}
}
let guard = Guard { core };
let res = guard.core.poll(cx);
mem::forget(guard);
res
}));
// Prepare output for being placed in the core stage.
let output = match output {
Ok(Poll::Pending) => return Poll::Pend... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 731dde21dc92e9cb9d25cf74a2b29e15cd364dbb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/731dde21dc92e9cb9d25cf74a2b29e15cd364dbb/tokio/src/runtime/task/harness.rs | 481 | 517 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:6 | TransitionToIdle::OkDealloc => PollFuture::Dealloc,
TransitionToIdle::Cancelled => PollFuture::Complete,
}
}
let header_ptr = self.header_ptr();
let waker_ref = waker_ref::<S>(&header_ptr);
let cx = Context::from... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/harness.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:7 | self.drop_reference();
return;
}
// By transitioning the lifecycle to `Running`, we have permission to
// drop the future.
cancel_task(self.core());
self.complete();
}
pub(super) fn dealloc(self) {
// Release the join waker, if there is one.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/runtime/task/harness.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:5 | // The remaining ref-count is now dropped. We kept the extra
// ref-count until now to ensure that even if the `yield_now`
// call drops the provided task, the task isn't deallocated
// before after `yield_now` returns.
self.drop_reference();
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 5128601898c788bd1f9cc044eee2859e3b213998 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5128601898c788bd1f9cc044eee2859e3b213998/tokio/src/runtime/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:5 | // The remaining ref-count is now dropped. We kept the extra
// ref-count until now to ensure that even if the `yield_now`
// call drops the provided task, the task isn't deallocated
// before after `yield_now` returns.
self.drop_reference();
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 304d14036184c9c65d88706e48dacb57bb172fcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/304d14036184c9c65d88706e48dacb57bb172fcc/tokio/src/runtime/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:6 | TransitionToIdle::OkDealloc => PollFuture::Dealloc,
TransitionToIdle::Cancelled => PollFuture::Complete,
}
}
let header_ptr = self.header_ptr();
let waker_ref = waker_ref::<T, S>(&header_ptr);
let cx = Context::f... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 304d14036184c9c65d88706e48dacb57bb172fcc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/304d14036184c9c65d88706e48dacb57bb172fcc/tokio/src/runtime/task/harness.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:1 | use crate::future::Future;
use crate::runtime::task::core::{Cell, Core, Header, Trailer};
use crate::runtime::task::state::{Snapshot, State};
use crate::runtime::task::waker::waker_ref;
use crate::runtime::task::{JoinError, Notified, RawTask, Schedule, Task};
use std::mem;
use std::mem::ManuallyDrop;
use std::panic;
u... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:2 | fn trailer(&self) -> &Trailer {
unsafe { &self.cell.as_ref().trailer }
}
fn core(&self) -> &Core<T, S> {
unsafe { &self.cell.as_ref().core }
}
}
/// Task operations that can be implemented without being generic over the
/// scheduler or task. Only one version of these methods should exist ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:3 | self.drop_reference();
}
TransitionToNotifiedByVal::Dealloc => {
self.dealloc();
}
TransitionToNotifiedByVal::DoNothing => {}
}
}
/// This call notifies the task. It will not consume any ref-counts, but the
/// caller should hold a ref... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:4 | // before the call to `schedule` returns even if the call drops the
// `Notified` internally.
self.schedule();
}
}
/// Try to set the waker notified when the task is complete. Returns true if
/// the task has already completed. If this call returns false, then the
/// wa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:5 | // ref-count until now to ensure that even if the `yield_now`
// call drops the provided task, the task isn't deallocated
// before after `yield_now` returns.
self.drop_reference();
}
PollFuture::Complete => {
self.complete();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:6 | // The future completed. Move on to complete the task.
return PollFuture::Complete;
}
match self.state().transition_to_idle() {
TransitionToIdle::Ok => PollFuture::Done,
TransitionToIdle::OkNotified => PollFuture::Notified,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:7 | cancel_task(self.core());
self.complete();
}
pub(super) fn dealloc(self) {
// Release the join waker, if there is one.
self.trailer().waker.with_mut(drop);
// Check causality
self.core().stage.with_mut(drop);
// Safety: The caller of this method just transition... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:8 | // case the task concurrently completed.
if self.state().unset_join_interested().is_err() {
// It is our responsibility to drop the output. This is critical as
// the task output may not be `Send` and as such must remain with
// the scheduler or `JoinHandle`. i.e. if the outp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:9 | // to transition_to_complete() above set the COMPLETE bit.
self.trailer().wake_join();
}
}));
// The task has completed execution and will no longer be scheduled.
let num_release = self.release();
if self.state().transition_to_terminal(num_release) {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:10 | }
}
fn can_read_output(header: &Header, trailer: &Trailer, waker: &Waker) -> bool {
// Load a snapshot of the current task state
let snapshot = header.state.load();
debug_assert!(snapshot.is_join_interested());
if !snapshot.is_complete() {
// If the task is not complete, try storing the provi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:11 | assert!(snapshot.is_complete());
}
}
}
true
}
fn set_join_waker(
header: &Header,
trailer: &Trailer,
waker: Waker,
snapshot: Snapshot,
) -> Result<Snapshot, Snapshot> {
assert!(snapshot.is_join_interested());
assert!(!snapshot.is_join_waker_set());
// Safety: On... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:12 | }
/// Cancels the task and store the appropriate error in the stage field.
fn cancel_task<T: Future, S: Schedule>(core: &Core<T, S>) {
// Drop the future from a panic guard.
let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
core.drop_future_or_output();
}));
match res {
Ok(())... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:13 | // Prepare output for being placed in the core stage.
let output = match output {
Ok(Poll::Pending) => return Poll::Pending,
Ok(Poll::Ready(output)) => Ok(output),
Err(panic) => {
core.scheduler.unhandled_panic();
Err(JoinError::panic(core.task_id, panic))
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | d9e0f6611351be6ec02fa95bfcd9fef710714eaf | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d9e0f6611351be6ec02fa95bfcd9fef710714eaf/tokio/src/runtime/task/harness.rs | 481 | 501 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:8 | // case the task concurrently completed.
if self.state().unset_join_interested().is_err() {
// It is our responsibility to drop the output. This is critical as
// the task output may not be `Send` and as such must remain with
// the scheduler or `JoinHandle`. i.e. if the outp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/task/harness.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:9 | self.trailer().wake_join();
}
}));
// The task has completed execution and will no longer be scheduled.
let num_release = self.release();
if self.state().transition_to_terminal(num_release) {
self.dealloc();
}
}
/// Releases the task from the sc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/task/harness.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:10 | }
fn can_read_output(header: &Header, trailer: &Trailer, waker: &Waker) -> bool {
// Load a snapshot of the current task state
let snapshot = header.state.load();
debug_assert!(snapshot.is_join_interested());
if !snapshot.is_complete() {
// The waker must be stored in the task struct.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/task/harness.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:11 | };
match res {
Ok(_) => return false,
Err(snapshot) => {
assert!(snapshot.is_complete());
}
}
}
true
}
fn set_join_waker(
header: &Header,
trailer: &Trailer,
waker: Waker,
snapshot: Snapshot,
) -> Result<Snapshot, Snapshot> {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/task/harness.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:12 | enum PollFuture {
Complete,
Notified,
Done,
Dealloc,
}
/// Cancels the task and store the appropriate error in the stage field.
fn cancel_task<T: Future, S: Schedule>(core: &Core<T, S>) {
// Drop the future from a panic guard.
let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:13 | let res = guard.core.poll(cx);
mem::forget(guard);
res
}));
// Prepare output for being placed in the core stage.
let output = match output {
Ok(Poll::Pending) => return Poll::Pending,
Ok(Poll::Ready(output)) => Ok(output),
Err(panic) => {
core.scheduler.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 22cff80048c62ed0fa20065888667d00d5aedd14 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/22cff80048c62ed0fa20065888667d00d5aedd14/tokio/src/runtime/task/harness.rs | 481 | 506 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:5 | // ref-count until now to ensure that even if the `yield_now`
// call drops the provided task, the task isn't deallocated
// before after `yield_now` returns.
self.drop_reference();
}
PollFuture::Complete => {
self.complete();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 45e37dbfa27162e3ecb1ca2a902a7d21eeecda8b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/45e37dbfa27162e3ecb1ca2a902a7d21eeecda8b/tokio/src/runtime/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:1 | use crate::future::Future;
use crate::runtime::task::core::{Cell, Core, Header, Trailer};
use crate::runtime::task::state::{Snapshot, State};
use crate::runtime::task::waker::waker_ref;
use crate::runtime::task::{JoinError, Notified, Schedule, Task};
use std::mem;
use std::mem::ManuallyDrop;
use std::panic;
use std::p... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/src/runtime/task/harness.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:2 | fn trailer(&self) -> &Trailer {
unsafe { &self.cell.as_ref().trailer }
}
fn core(&self) -> &Core<T, S> {
unsafe { &self.cell.as_ref().core }
}
}
impl<T, S> Harness<T, S>
where
T: Future,
S: Schedule,
{
/// Polls the inner future. A ref-count is consumed.
///
/// All nec... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/src/runtime/task/harness.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:3 | PollFuture::Done => (),
}
}
/// Polls the task and cancel it if necessary. This takes ownership of a
/// ref-count.
///
/// If the return value is Notified, the caller is given ownership of two
/// ref-counts.
///
/// If the return value is Complete, the caller is given ownershi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/src/runtime/task/harness.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:4 | cancel_task(self.core());
PollFuture::Complete
}
}
}
TransitionToRunning::Cancelled => {
cancel_task(self.core());
PollFuture::Complete
}
TransitionToRunning::Failed => PollFuture:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/src/runtime/task/harness.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:5 | // Safety: The caller of this method just transitioned our ref-count to
// zero, so it is our responsibility to release the allocation.
//
// We don't hold any references into the allocation at this point, but
// it is possible for another thread to still hold a `&State` into the
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/src/runtime/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:6 | // the scheduler or `JoinHandle`. i.e. if the output remains in the
// task structure until the task is deallocated, it may be dropped
// by a Waker on any arbitrary thread.
//
// Panics are delivered to the user via the `JoinHandle`. Given that
// they are dr... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/src/runtime/task/harness.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:7 | /// new Notified and submit it if necessary.
///
/// The caller does not need to hold a ref-count besides the one that was
/// passed to this call.
pub(super) fn wake_by_val(self) {
use super::state::TransitionToNotifiedByVal;
match self.state().transition_to_notified_by_val() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/src/runtime/task/harness.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/task/harness.rs:8 | // and the caller also holds a ref-count. The caller's ref-count
// ensures that the task is not destroyed even if the new task
// is dropped before `schedule` returns.
self.core()
.scheduler
.schedule(Notified(self.get_new_task()))... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/task/harness.rs | MIT | 71bd49e146ac5288fd4cb327dd3f86eb71b3a865 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/71bd49e146ac5288fd4cb327dd3f86eb71b3a865/tokio/src/runtime/task/harness.rs | 281 | 340 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.