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/harness.rs:3 | // If the task's executor pointer is not yet set, then set it here. This
// is safe because a) this is the only time the value is set. b) at this
// point, there are no outstanding wakers which might access the
// field concurrently.
if header.executor().is_none() {
// We don... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/task/harness.rs:4 | // prevent the guard from dropping the future
guard.polled = true;
res
}))
});
match res {
Ok(Poll::Ready(out)) => {
self.complete(executor, join_interest, Ok(out));
false
}
Ok(Poll::Pending... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/task/harness.rs:5 | let res = self.header().state.release_task();
assert!(res.is_terminal(), "state = {:?}", res);
if might_drop_join_waker_on_release && !res.is_join_interested() {
debug_assert!(res.has_join_waker());
// Its our responsibility to drop the waker
let _ = join_waker.ass... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/harness.rs:6 | // Before transitioning the state, the waker must be read. It is
// possible that, after the transition, we are responsible for dropping
// the waker but before the waker can be read from the struct, the
// struct is deallocated.
let waker = self.read_join_waker();
// The operat... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/task/harness.rs:7 | unsafe {
let will_wake = self
.trailer()
.waker
.with(|ptr| (*(*ptr).as_ptr()).as_ref().unwrap().will_wake(waker));
if will_wake {
return prev;
}
// Acquire the lock
let state = self.header().st... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/harness.rs:8 | self.header().state.complete_join_handle()
}
};
if !(res.is_complete() | res.is_canceled()) || res.is_released() {
// We are responsible for freeing the waker handle
drop(waker.assume_init());
}
if res.is_final_ref() {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/harness.rs:9 | }
}
/// Cancel the task.
///
/// `from_queue` signals the caller is cancelling the task after popping it
/// from the queue. This indicates "polling" capability.
pub(super) fn cancel(self, from_queue: bool) {
let res = if from_queue {
self.header().state.transition_to_cancel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/harness.rs:10 | });
// If there is a join waker, we must notify it so it can observe the
// task was canceled.
if res.is_join_interested() && res.has_join_waker() {
// Notify the join handle. The transition to cancelled obtained a
// lock on the waker cell.
unsafe {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/task/harness.rs:11 | output: super::Result<T::Output>,
) {
if join_interest {
// Store the output. The future has already been dropped
self.core().store_output(output);
}
let executor = executor();
let bound_executor = unsafe { self.header().executor.with(|ptr| *ptr) };
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/harness.rs:12 | let task = self.to_task();
let executor = match bound_executor {
Some(executor) => executor,
None => panic!("executor should be set"),
};
executor.cast::<S>().as_ref().release(task);
}
}
}
/// Returns ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/harness.rs:13 | if res1.has_join_waker() && !res2.is_join_interested() {
debug_assert!(res2.has_join_waker());
// Its our responsibility to drop the waker
unsafe {
drop(join_waker.assume_init());
}
}
res2
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/harness.rs:14 | fn might_drop_join_waker_on_release(&self) -> bool {
unsafe {
let next = *self.header().queue_next.get() as usize;
next & 1 == 1
}
}
fn set_might_drop_join_waker_on_release(&self) {
unsafe {
debug_assert!(
(*self.header().queue_next.ge... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 560d0fa548314e223601ed83429daf237d72afbd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/560d0fa548314e223601ed83429daf237d72afbd/tokio/src/task/harness.rs | 521 | 558 |
tokio-rs/tokio:tokio/src/task/harness.rs:1 | use crate::loom::alloc::Track;
use crate::loom::cell::CausalCheck;
use crate::task::core::{Cell, Core, Header, Trailer};
use crate::task::state::Snapshot;
use crate::task::{JoinError, Schedule, Task};
use std::future::Future;
use std::marker::PhantomData;
use std::mem::{ManuallyDrop, MaybeUninit};
use std::ptr::NonNul... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/task/harness.rs:2 | fn core(&mut self) -> &mut Core<T> {
unsafe { &mut self.cell.as_mut().core }
}
}
impl<T, S> Harness<T, S>
where
T: Future,
S: Schedule,
{
/// Polls the inner future.
///
/// All necessary state checks and transitions are performed.
///
/// Panics raised while polling the future ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/task/harness.rs:3 | // If the task's executor pointer is not yet set, then set it here. This
// is safe because a) this is the only time the value is set. b) at this
// point, there are no outstanding wakers which might access the
// field concurrently.
if header.executor().is_none() {
// We don... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/task/harness.rs:4 | // prevent the guard from dropping the future
guard.polled = true;
res
}))
});
match res {
Ok(Poll::Ready(out)) => {
self.complete(executor, join_interest, Ok(out));
false
}
Ok(Poll::Pending... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/task/harness.rs:5 | if might_drop_join_waker_on_release && !res.is_join_interested() {
debug_assert!(res.has_join_waker());
// Its our responsibility to drop the waker
check.check();
let _ = join_waker.assume_init();
}
if res.is_final_ref() {
self.dealloc();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/harness.rs:6 | // possible that, after the transition, we are responsible for dropping
// the waker but before the waker can be read from the struct, the
// struct is deallocated.
let (waker, check) = self.read_join_waker();
// The operation counts as dropping the join handle
let res = self.he... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/task/harness.rs:7 | let will_wake = self
.trailer()
.waker
.with(|ptr| (*(*ptr).as_ptr()).as_ref().unwrap().will_wake(waker));
if will_wake {
return prev;
}
// Acquire the lock
let state = self.header().state.unset_waker();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/harness.rs:8 | }
};
if !(res.is_complete() | res.is_canceled()) || res.is_released() {
// We are responsible for freeing the waker handle
check.check();
drop(waker.assume_init());
}
if res.is_final_ref() {
self.dealloc();... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/harness.rs:12 | let task = self.to_task();
let executor = match bound_executor {
Some(executor) => executor,
None => panic!("executor should be set"),
};
executor.cast::<S>().as_ref().release(task);
}
}
}
/// Returns ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/harness.rs:13 | check.check();
unsafe {
drop(join_waker.assume_init());
}
}
res2
} else {
self.header().state.transition_to_released()
}
}
fn notify_join_handle(&mut self, join_interest: bool, res: Snapshot) {
if j... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/harness.rs:14 | next & 1 == 1
}
}
fn set_might_drop_join_waker_on_release(&self) {
unsafe {
debug_assert!(
(*self.header().queue_next.get()).is_null(),
"the task's queue_next field must be null when releasing"
);
*self.header().queue_next.get... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | f9ddb93604a830d106475bd4c4cae436fafcc0da | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f9ddb93604a830d106475bd4c4cae436fafcc0da/tokio/src/task/harness.rs | 521 | 555 |
tokio-rs/tokio:tokio/src/task/harness.rs:1 | use crate::loom::alloc::Track;
use crate::loom::cell::CausalCheck;
use crate::task::core::{Cell, Core, Header, Trailer};
use crate::task::state::Snapshot;
use crate::task::{JoinError, Schedule, Task};
use std::future::Future;
use std::marker::PhantomData;
use std::mem::{ManuallyDrop, MaybeUninit};
use std::ptr::NonNul... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 5930acef736d45733dc182e420a2417a164c71ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/harness.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/task/harness.rs:2 | fn core(&mut self) -> &mut Core<T> {
unsafe { &mut self.cell.as_mut().core }
}
}
impl<T, S> Harness<T, S>
where
T: Future,
S: Schedule,
{
/// Poll the inner future.
///
/// All necessary state checks and transitions are performed.
///
/// Panics raised while polling the future a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 5930acef736d45733dc182e420a2417a164c71ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/harness.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/task/harness.rs:11 | output: super::Result<T::Output>,
) {
if join_interest {
// Store the output. The future has already been dropped
self.core().store_output(output);
}
let executor = executor();
let bound_executor = unsafe { self.header().executor.with(|ptr| *ptr) };
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 5930acef736d45733dc182e420a2417a164c71ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/harness.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/harness.rs:12 | let task = self.to_task();
let executor = match bound_executor {
Some(executor) => executor,
None => panic!("executor should be set"),
};
executor.cast::<S>().as_ref().release(task);
}
}
}
/// Return `... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 5930acef736d45733dc182e420a2417a164c71ba | github | async-runtime | https://github.com/tokio-rs/tokio/blob/5930acef736d45733dc182e420a2417a164c71ba/tokio/src/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/harness.rs:8 | }
};
if !(res.is_complete() | res.is_canceled()) || res.is_released() {
// We are responsible for freeing the waker handle
check.check();
drop(waker.assume_init());
}
if res.is_final_ref() {
self.dealloc();... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | cbe369a3ed5c252ca7581e37986dc912d88e58c6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbe369a3ed5c252ca7581e37986dc912d88e58c6/tokio/src/task/harness.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/harness.rs:9 | if self.header().state.ref_dec() {
unsafe {
self.dealloc();
}
}
}
/// Cancel the task.
///
/// `from_queue` signals the caller is cancelling the task after popping it
/// from the queue. This indicates "polling" capability.
pub(super) fn cancel(se... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | cbe369a3ed5c252ca7581e37986dc912d88e58c6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbe369a3ed5c252ca7581e37986dc912d88e58c6/tokio/src/task/harness.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/harness.rs:10 | let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| {
// Drop the future
core.transition_to_consumed();
}));
});
// If there is a join waker, we must notify it so it can observe the
// task was canceled.
if res.is_join_interested() && res.h... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | cbe369a3ed5c252ca7581e37986dc912d88e58c6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbe369a3ed5c252ca7581e37986dc912d88e58c6/tokio/src/task/harness.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/task/harness.rs:11 | fn complete(
mut self,
executor: &mut dyn FnMut() -> Option<NonNull<()>>,
join_interest: bool,
output: super::Result<T::Output>,
) {
if join_interest {
// Store the output. The future has already been dropped
self.core().store_output(output);
}... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | cbe369a3ed5c252ca7581e37986dc912d88e58c6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbe369a3ed5c252ca7581e37986dc912d88e58c6/tokio/src/task/harness.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/task/harness.rs:12 | self.set_might_drop_join_waker_on_release();
}
unsafe {
let task = self.to_task();
let executor = match bound_executor {
Some(executor) => executor,
None => panic!("executor should be set"),
};
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | cbe369a3ed5c252ca7581e37986dc912d88e58c6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbe369a3ed5c252ca7581e37986dc912d88e58c6/tokio/src/task/harness.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/harness.rs:13 | if res1.has_join_waker() && !res2.is_join_interested() {
debug_assert!(res2.has_join_waker());
// Its our responsibility to drop the waker
check.check();
unsafe {
drop(join_waker.assume_init());
}
}
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | cbe369a3ed5c252ca7581e37986dc912d88e58c6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbe369a3ed5c252ca7581e37986dc912d88e58c6/tokio/src/task/harness.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/harness.rs:14 | fn might_drop_join_waker_on_release(&self) -> bool {
unsafe {
let next = *self.header().queue_next.get() as usize;
next & 1 == 1
}
}
fn set_might_drop_join_waker_on_release(&self) {
unsafe {
debug_assert!(
(*self.header().queue_next.ge... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | cbe369a3ed5c252ca7581e37986dc912d88e58c6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/cbe369a3ed5c252ca7581e37986dc912d88e58c6/tokio/src/task/harness.rs | 521 | 559 |
tokio-rs/tokio:tokio/src/task/harness.rs:4 | // prevent the guard from dropping the future
guard.polled = true;
res
}))
});
match res {
Ok(Poll::Ready(out)) => {
self.complete(executor, join_interest, Ok(out));
false
}
Ok(Poll::Pending... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 942feab040e28d1e1547012a0fb81212299e6596 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/942feab040e28d1e1547012a0fb81212299e6596/tokio/src/task/harness.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/task/harness.rs:5 | if might_drop_join_waker_on_release && !res.is_join_interested() {
debug_assert!(res.has_join_waker());
// Its our responsibility to drop the waker
check.check();
let _ = join_waker.assume_init();
}
if res.is_final_ref() {
self.dealloc();
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/harness.rs | MIT | 942feab040e28d1e1547012a0fb81212299e6596 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/942feab040e28d1e1547012a0fb81212299e6596/tokio/src/task/harness.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/join.rs:2 | ///
/// # async fn doc() {
/// let join_handle: task::JoinHandle<_> = task::spawn_blocking(|| {
/// // some blocking work here
/// });
/// # }
/// ```
///
/// Child being detached and outliving its parent:
///
/// ```no_run
/// use tokio::task;
/// use tokio::time;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join.rs | MIT | 8b60c5386a60be4dacffe71823350040e8ba90fd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8b60c5386a60be4dacffe71823350040e8ba90fd/tokio/src/task/join.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/task/join.rs:3 | _p: PhantomData<T>,
}
}
unsafe impl<T: Send> Send for JoinHandle<T> {}
unsafe impl<T: Send> Sync for JoinHandle<T> {}
impl<T> JoinHandle<T> {
pub(super) fn new(raw: RawTask) -> JoinHandle<T> {
JoinHandle {
raw: Some(raw),
_p: PhantomData,
}
}
}
impl<T> Unpin for Jo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join.rs | MIT | 8b60c5386a60be4dacffe71823350040e8ba90fd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8b60c5386a60be4dacffe71823350040e8ba90fd/tokio/src/task/join.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/task/join.rs:4 | return Poll::Pending;
}
}
let mut out = MaybeUninit::<Track<Self::Output>>::uninit();
unsafe {
// This could result in the task being freed.
raw.read_output(out.as_mut_ptr() as *mut (), state);
self.raw = None;
Poll::Ready(out.assum... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join.rs | MIT | 8b60c5386a60be4dacffe71823350040e8ba90fd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8b60c5386a60be4dacffe71823350040e8ba90fd/tokio/src/task/join.rs | 121 | 157 |
tokio-rs/tokio:tokio/src/task/join.rs:2 | /// # async fn doc() {
/// let join_handle: task::JoinHandle<_> = task::spawn_blocking(|| {
/// // some blocking work here
/// });
/// # }
/// ```
///
/// Child being detached and outliving its parent:
///
/// ```no_run
/// use tokio::task;
/// use tokio::time;
/// use std::time::Duration;
///
/// # #[tokio::main] ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join.rs | MIT | c223db35896bd6b6714d4793cd84290e573bb216 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c223db35896bd6b6714d4793cd84290e573bb216/tokio/src/task/join.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/task/join.rs:3 | }
unsafe impl<T: Send> Send for JoinHandle<T> {}
unsafe impl<T: Send> Sync for JoinHandle<T> {}
impl<T> JoinHandle<T> {
pub(super) fn new(raw: RawTask) -> JoinHandle<T> {
JoinHandle {
raw: Some(raw),
_p: PhantomData,
}
}
}
impl<T> Unpin for JoinHandle<T> {}
impl<T> Fu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join.rs | MIT | c223db35896bd6b6714d4793cd84290e573bb216 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c223db35896bd6b6714d4793cd84290e573bb216/tokio/src/task/join.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/task/join.rs:4 | }
let mut out = MaybeUninit::<Track<Self::Output>>::uninit();
unsafe {
// This could result in the task being freed.
raw.read_output(out.as_mut_ptr() as *mut (), state);
self.raw = None;
Poll::Ready(out.assume_init().into_inner())
}
}
}
im... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join.rs | MIT | c223db35896bd6b6714d4793cd84290e573bb216 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c223db35896bd6b6714d4793cd84290e573bb216/tokio/src/task/join.rs | 121 | 155 |
tokio-rs/tokio:tokio/src/task/join_set.rs:2 | ///
/// let mut seen = [false; 10];
/// while let Some(res) = set.join_next().await {
/// let idx = res.unwrap();
/// seen[idx] = true;
/// }
///
/// for i in 0..10 {
/// assert!(seen[i]);
/// }
/// # }
/// ```
///
/// # Task ID guarantees
///
/// While a task is tracked in a `JoinSet`, that task's ID is un... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/task/join_set.rs:3 | /// Create a new `JoinSet`.
pub fn new() -> Self {
Self {
inner: IdleNotifiedSet::new(),
}
}
/// Returns the number of tasks currently in the `JoinSet`.
pub fn len(&self) -> usize {
self.inner.len()
}
/// Returns whether the `JoinSet` is empty.
pub fn is... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/task/join_set.rs:4 | #[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))]
pub fn build_task(&mut self) -> Builder<'_, T> {
Builder {
builder: super::Builder::new(),
joinset: self,
}
}
/// Spawn the provided task on the `JoinSet`, returning an [`AbortHandle`]
/// th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/task/join_set.rs:5 | pub fn spawn_on<F>(&mut self, task: F, handle: &Handle) -> AbortHandle
where
F: Future<Output = T>,
F: Send + 'static,
T: Send,
{
self.insert(handle.spawn(task))
}
/// Spawn the provided task on the current [`LocalSet`] or [`LocalRuntime`]
/// and store it in this `J... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/join_set.rs:6 | ///
/// [`LocalSet`]: crate::task::LocalSet
/// [`AbortHandle`]: crate::task::AbortHandle
/// [`spawn_local`]: Self::spawn_local
#[track_caller]
pub fn spawn_local_on<F>(&mut self, task: F, local_set: &LocalSet) -> AbortHandle
where
F: Future<Output = T>,
F: 'static,
{
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/task/join_set.rs:7 | /// for i in 0..10 {
/// assert!(seen[i]);
/// }
/// }
/// # }
/// ```
///
/// # Panics
///
/// This method panics if called outside of a Tokio runtime.
///
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_blocking<F>(&mut sel... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/join_set.rs:8 | // Set the waker that is notified when the task completes.
entry.with_value_and_context(|jh, ctx| jh.set_join_waker(ctx.waker()));
abort
}
/// Waits until one of the tasks in the set completes and returns its output.
///
/// Returns `None` if the set is empty.
///
/// # Cancel S... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | ///
/// Returns `None` if there are no completed tasks, or if the set is empty.
pub fn try_join_next(&mut self) -> Option<Result<T, JoinError>> {
// Loop over all notified `JoinHandle`s to find one that's ready, or until none are left.
loop {
let mut entry = self.inner.try_pop_notifi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | /// assert_eq!(output.len(),3);
/// # }
/// ```
/// [`join_next`]: fn@Self::join_next
/// [`JoinError::id`]: fn@crate::task::JoinError::id
pub async fn join_all(mut self) -> Vec<T> {
let mut output = Vec::with_capacity(self.len());
while let Some(res) = self.join_next().await {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | /// `poll_join_next`, only the `Waker` from the `Context` passed to the most recent call is
/// scheduled to receive a wakeup.
///
/// # Returns
///
/// This function returns:
///
/// * `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | // A JoinHandle generally won't emit a wakeup without being ready unless
// the coop limit has been reached. We yield to the executor in this
// case.
cx.waker().wake_by_ref();
Poll::Pending
}
}
/// Polls for one of the tasks in the set to complete.
/... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:15 | // the `notified` list if the waker is notified in the `poll` call below.
let mut entry = match self.inner.pop_notified(cx.waker()) {
Some(entry) => entry,
None => {
if self.is_empty() {
return Poll::Ready(None);
} else {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/task/join_set.rs:16 | }
impl<T> Default for JoinSet<T> {
fn default() -> Self {
Self::new()
}
}
/// Collect an iterator of futures into a [`JoinSet`].
///
/// This is equivalent to calling [`JoinSet::spawn`] on each element of the iterator.
///
/// # Examples
///
/// The main example from [`JoinSet`]'s documentation can al... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/task/join_set.rs:17 | T: Send + 'static,
{
fn from_iter<I: IntoIterator<Item = F>>(iter: I) -> Self {
let mut set = Self::new();
iter.into_iter().for_each(|task| {
set.spawn(task);
});
set
}
}
/// Extend a [`JoinSet`] with futures from an iterator.
///
/// This is equivalent to calling [`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/task/join_set.rs:18 | impl<T, F> std::iter::Extend<F> for JoinSet<T>
where
F: Future<Output = T>,
F: Send + 'static,
T: Send + 'static,
{
fn extend<I>(&mut self, iter: I)
where
I: IntoIterator<Item = F>,
{
iter.into_iter().for_each(|task| {
self.spawn(task);
});
}
}
// === imp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/task/join_set.rs:19 | #[track_caller]
pub fn spawn<F>(self, future: F) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.spawn(future)?))
}
/// Spawn the provided task on the provided [runtime handle] with this
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/task/join_set.rs:20 | ///
/// [`JoinSet`]: crate::task::JoinSet
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_blocking<F>(self, f: F) -> std::io::Result<AbortHandle>
where
F: FnOnce() -> T,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 761 | 820 |
tokio-rs/tokio:tokio/src/task/join_set.rs:21 | /// An [`AbortHandle`] that can be used to remotely cancel the task.
///
/// # Panics
///
/// This method panics if it is called outside of a `LocalSet` or `LocalRuntime`.
///
/// [`LocalSet`]: crate::task::LocalSet
/// [`LocalRuntime`]: crate::runtime::LocalRuntime
/// [`AbortHandle`]: ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 801 | 851 |
tokio-rs/tokio:tokio/src/task/join_set.rs:22 | // `Debug`.
#[cfg(all(tokio_unstable, feature = "tracing"))]
#[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))]
impl<'a, T> fmt::Debug for Builder<'a, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("join_set::Builder")
.field("joinset", &self.... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/task/join_set.rs | 841 | 851 |
tokio-rs/tokio:tokio/src/task/join_set.rs:16 | }
impl<T> Default for JoinSet<T> {
fn default() -> Self {
Self::new()
}
}
/// Collect an iterator of futures into a [`JoinSet`].
///
/// This is equivalent to calling [`JoinSet::spawn`] on each element of the iterator.
///
/// # Examples
///
/// The main example from [`JoinSet`]'s documentation can al... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | d25778f67d4571f9067a0004133d5a9005b6aedd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d25778f67d4571f9067a0004133d5a9005b6aedd/tokio/src/task/join_set.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/task/join_set.rs:17 | T: Send + 'static,
{
fn from_iter<I: IntoIterator<Item = F>>(iter: I) -> Self {
let mut set = Self::new();
iter.into_iter().for_each(|task| {
set.spawn(task);
});
set
}
}
// === impl Builder ===
#[cfg(all(tokio_unstable, feature = "tracing"))]
#[cfg_attr(docsrs, doc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | d25778f67d4571f9067a0004133d5a9005b6aedd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d25778f67d4571f9067a0004133d5a9005b6aedd/tokio/src/task/join_set.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/task/join_set.rs:18 | T: Send,
{
Ok(self.joinset.insert(self.builder.spawn(future)?))
}
/// Spawn the provided task on the provided [runtime handle] with this
/// builder's settings, and store it in the [`JoinSet`].
///
/// # Returns
///
/// An [`AbortHandle`] that can be used to remotely cancel the ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | d25778f67d4571f9067a0004133d5a9005b6aedd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d25778f67d4571f9067a0004133d5a9005b6aedd/tokio/src/task/join_set.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/task/join_set.rs:19 | where
F: FnOnce() -> T,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.spawn_blocking(f)?))
}
/// Spawn the blocking code on the blocking threadpool of the provided
/// runtime handle with this builder's settings, and store it in the
/// [`JoinSet`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | d25778f67d4571f9067a0004133d5a9005b6aedd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d25778f67d4571f9067a0004133d5a9005b6aedd/tokio/src/task/join_set.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/task/join_set.rs:20 | ///
/// [`LocalSet`]: crate::task::LocalSet
/// [`LocalRuntime`]: crate::runtime::LocalRuntime
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_local<F>(self, future: F) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: 'static,
{
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | d25778f67d4571f9067a0004133d5a9005b6aedd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d25778f67d4571f9067a0004133d5a9005b6aedd/tokio/src/task/join_set.rs | 761 | 806 |
tokio-rs/tokio:tokio/src/task/join_set.rs:4 | #[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))]
pub fn build_task(&mut self) -> Builder<'_, T> {
Builder {
builder: super::Builder::new(),
joinset: self,
}
}
/// Spawn the provided task on the `JoinSet`, returning an [`AbortHandle`]
/// th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c1fa25f3009d6f5374e337b999fe4fe926c8e7f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/join_set.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/task/join_set.rs:5 | pub fn spawn_on<F>(&mut self, task: F, handle: &Handle) -> AbortHandle
where
F: Future<Output = T>,
F: Send + 'static,
T: Send,
{
self.insert(handle.spawn(task))
}
/// Spawn the provided task on the current [`LocalSet`] or [`LocalRuntime`]
/// and store it in this `J... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c1fa25f3009d6f5374e337b999fe4fe926c8e7f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/join_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/join_set.rs:19 | where
F: FnOnce() -> T,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.spawn_blocking(f)?))
}
/// Spawn the blocking code on the blocking threadpool of the provided
/// runtime handle with this builder's settings, and store it in the
/// [`JoinSet`... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c1fa25f3009d6f5374e337b999fe4fe926c8e7f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/join_set.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/task/join_set.rs:20 | ///
/// [`LocalSet`]: crate::task::LocalSet
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_local<F>(self, future: F) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: 'static,
{
Ok(self.joinset.insert(self.builder.spawn_local(futu... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | c1fa25f3009d6f5374e337b999fe4fe926c8e7f2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c1fa25f3009d6f5374e337b999fe4fe926c8e7f2/tokio/src/task/join_set.rs | 761 | 805 |
tokio-rs/tokio:tokio/src/task/join_set.rs:4 | #[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))]
pub fn build_task(&mut self) -> Builder<'_, T> {
Builder {
builder: super::Builder::new(),
joinset: self,
}
}
/// Spawn the provided task on the `JoinSet`, returning an [`AbortHandle`]
/// th... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/task/join_set.rs:5 | pub fn spawn_on<F>(&mut self, task: F, handle: &Handle) -> AbortHandle
where
F: Future<Output = T>,
F: Send + 'static,
T: Send,
{
self.insert(handle.spawn(task))
}
/// Spawn the provided task on the current [`LocalSet`] and store it in this
/// `JoinSet`, returning a... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/task/join_set.rs:6 | /// [`LocalSet`]: crate::task::LocalSet
/// [`AbortHandle`]: crate::task::AbortHandle
/// [`spawn_local`]: Self::spawn_local
#[track_caller]
pub fn spawn_local_on<F>(&mut self, task: F, local_set: &LocalSet) -> AbortHandle
where
F: Future<Output = T>,
F: 'static,
{
self.i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/task/join_set.rs:7 | /// assert!(seen[i]);
/// }
/// }
/// # }
/// ```
///
/// # Panics
///
/// This method panics if called outside of a Tokio runtime.
///
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_blocking<F>(&mut self, f: F) -> AbortHandle
w... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | /// Returns `None` if there are no completed tasks, or if the set is empty.
pub fn try_join_next(&mut self) -> Option<Result<T, JoinError>> {
// Loop over all notified `JoinHandle`s to find one that's ready, or until none are left.
loop {
let mut entry = self.inner.try_pop_notified()?;
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | /// # }
/// ```
/// [`join_next`]: fn@Self::join_next
/// [`JoinError::id`]: fn@crate::task::JoinError::id
pub async fn join_all(mut self) -> Vec<T> {
let mut output = Vec::with_capacity(self.len());
while let Some(res) = self.join_next().await {
match res {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | /// scheduled to receive a wakeup.
///
/// # Returns
///
/// This function returns:
///
/// * `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available right now.
/// * `Poll::Ready(Some(Ok(value)))` if one of the tasks in this `JoinSet` has co... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | // the coop limit has been reached. We yield to the executor in this
// case.
cx.waker().wake_by_ref();
Poll::Pending
}
}
/// Polls for one of the tasks in the set to complete.
///
/// If this returns `Poll::Ready(Some(_))`, then the task that completed is re... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:15 | let mut entry = match self.inner.pop_notified(cx.waker()) {
Some(entry) => entry,
None => {
if self.is_empty() {
return Poll::Ready(None);
} else {
// The waker was set by `pop_notified`.
return Poll::Pen... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/task/join_set.rs:16 | impl<T> Default for JoinSet<T> {
fn default() -> Self {
Self::new()
}
}
/// Collect an iterator of futures into a [`JoinSet`].
///
/// This is equivalent to calling [`JoinSet::spawn`] on each element of the iterator.
///
/// # Examples
///
/// The main example from [`JoinSet`]'s documentation can also ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/task/join_set.rs:17 | {
fn from_iter<I: IntoIterator<Item = F>>(iter: I) -> Self {
let mut set = Self::new();
iter.into_iter().for_each(|task| {
set.spawn(task);
});
set
}
}
// === impl Builder ===
#[cfg(all(tokio_unstable, feature = "tracing"))]
#[cfg_attr(docsrs, doc(cfg(all(tokio_unst... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/task/join_set.rs:18 | {
Ok(self.joinset.insert(self.builder.spawn(future)?))
}
/// Spawn the provided task on the provided [runtime handle] with this
/// builder's settings, and store it in the [`JoinSet`].
///
/// # Returns
///
/// An [`AbortHandle`] that can be used to remotely cancel the task.
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/task/join_set.rs:19 | F: FnOnce() -> T,
F: Send + 'static,
T: Send,
{
Ok(self.joinset.insert(self.builder.spawn_blocking(f)?))
}
/// Spawn the blocking code on the blocking threadpool of the provided
/// runtime handle with this builder's settings, and store it in the
/// [`JoinSet`].
///
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/task/join_set.rs:20 | /// [`LocalSet`]: crate::task::LocalSet
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_local<F>(self, future: F) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: 'static,
{
Ok(self.joinset.insert(self.builder.spawn_local(future)?))
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8ccf2fb92e7568bf16318dc8f3205cad14a9bc5d/tokio/src/task/join_set.rs | 761 | 804 |
tokio-rs/tokio:tokio/src/task/join_set.rs:2 | ///
/// let mut seen = [false; 10];
/// while let Some(res) = set.join_next().await {
/// let idx = res.unwrap();
/// seen[idx] = true;
/// }
///
/// for i in 0..10 {
/// assert!(seen[i]);
/// }
/// }
/// ```
///
/// # Task ID guarantees
///
/// While a task is tracked in a `... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/task/join_set.rs:6 | /// [`LocalSet`]: crate::task::LocalSet
/// [`AbortHandle`]: crate::task::AbortHandle
/// [`spawn_local`]: Self::spawn_local
#[track_caller]
pub fn spawn_local_on<F>(&mut self, task: F, local_set: &LocalSet) -> AbortHandle
where
F: Future<Output = T>,
F: 'static,
{
self.i... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/task/join_set.rs:7 | /// }
/// ```
///
/// # Panics
///
/// This method panics if called outside of a Tokio runtime.
///
/// [`AbortHandle`]: crate::task::AbortHandle
#[track_caller]
pub fn spawn_blocking<F>(&mut self, f: F) -> AbortHandle
where
F: FnOnce() -> T,
F: Send + 'static,
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/task/join_set.rs:8 | }
/// Waits until one of the tasks in the set completes and returns its output.
///
/// Returns `None` if the set is empty.
///
/// # Cancel Safety
///
/// This method is cancel safe. If `join_next` is used as the event in a `tokio::select!`
/// statement and some other branch completes... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/task/join_set.rs:9 | loop {
let mut entry = self.inner.try_pop_notified()?;
let res = entry.with_value_and_context(|jh, ctx| {
// Since this function is not async and cannot be forced to yield, we should
// disable budgeting when we want to check for the `JoinHandle` readiness.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/task/join_set.rs:12 | /// [`JoinError::id`]: fn@crate::task::JoinError::id
pub async fn join_all(mut self) -> Vec<T> {
let mut output = Vec::with_capacity(self.len());
while let Some(res) = self.join_next().await {
match res {
Ok(t) => output.push(t),
Err(err) if err.is_panic(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/task/join_set.rs:13 | ///
/// This function returns:
///
/// * `Poll::Pending` if the `JoinSet` is not empty but there is no task whose output is
/// available right now.
/// * `Poll::Ready(Some(Ok(value)))` if one of the tasks in this `JoinSet` has completed.
/// The `value` is the return value of one of the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 481 | 540 |
tokio-rs/tokio:tokio/src/task/join_set.rs:14 | Poll::Pending
}
}
/// Polls for one of the tasks in the set to complete.
///
/// If this returns `Poll::Ready(Some(_))`, then the task that completed is removed from the set.
///
/// When the method returns `Poll::Pending`, the `Waker` in the provided `Context` is scheduled
/// to r... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 521 | 580 |
tokio-rs/tokio:tokio/src/task/join_set.rs:15 | if self.is_empty() {
return Poll::Ready(None);
} else {
// The waker was set by `pop_notified`.
return Poll::Pending;
}
}
};
let res = entry.with_value_and_context(|jh, ctx| Pin::new(jh).poll(ctx));
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 561 | 620 |
tokio-rs/tokio:tokio/src/task/join_set.rs:16 | Self::new()
}
}
/// Collect an iterator of futures into a [`JoinSet`].
///
/// This is equivalent to calling [`JoinSet::spawn`] on each element of the iterator.
///
/// # Examples
///
/// The main example from [`JoinSet`]'s documentation can also be written using [`collect`]:
///
/// ```
/// use tokio::task::JoinS... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 601 | 660 |
tokio-rs/tokio:tokio/src/task/join_set.rs:17 | iter.into_iter().for_each(|task| {
set.spawn(task);
});
set
}
}
// === impl Builder ===
#[cfg(all(tokio_unstable, feature = "tracing"))]
#[cfg_attr(docsrs, doc(cfg(all(tokio_unstable, feature = "tracing"))))]
impl<'a, T: 'static> Builder<'a, T> {
/// Assigns a name to the task whic... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 641 | 700 |
tokio-rs/tokio:tokio/src/task/join_set.rs:18 | /// Spawn the provided task on the provided [runtime handle] with this
/// builder's settings, and store it in the [`JoinSet`].
///
/// # Returns
///
/// An [`AbortHandle`] that can be used to remotely cancel the task.
///
///
/// [`AbortHandle`]: crate::task::AbortHandle
/// [runtim... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 681 | 740 |
tokio-rs/tokio:tokio/src/task/join_set.rs:19 | {
Ok(self.joinset.insert(self.builder.spawn_blocking(f)?))
}
/// Spawn the blocking code on the blocking threadpool of the provided
/// runtime handle with this builder's settings, and store it in the
/// [`JoinSet`].
///
/// # Returns
///
/// An [`AbortHandle`] that can be used... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 721 | 780 |
tokio-rs/tokio:tokio/src/task/join_set.rs:20 | pub fn spawn_local<F>(self, future: F) -> std::io::Result<AbortHandle>
where
F: Future<Output = T>,
F: 'static,
{
Ok(self.joinset.insert(self.builder.spawn_local(future)?))
}
/// Spawn the provided task on the provided [`LocalSet`] with this builder's
/// settings, and store... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | 7f455b2d9334c89dba03d9dd49a19cc56b791ecd | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7f455b2d9334c89dba03d9dd49a19cc56b791ecd/tokio/src/task/join_set.rs | 761 | 801 |
tokio-rs/tokio:tokio/src/task/join_set.rs:2 | ///
/// let mut seen = [false; 10];
/// while let Some(res) = set.join_next().await {
/// let idx = res.unwrap();
/// seen[idx] = true;
/// }
///
/// for i in 0..10 {
/// assert!(seen[i]);
/// }
/// }
/// ```
#[cfg_attr(docsrs, doc(cfg(feature = "rt")))]
pub struct JoinSet<T>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/task/join_set.rs:3 | }
/// Returns whether the `JoinSet` is empty.
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
}
impl<T: 'static> JoinSet<T> {
/// Returns a [`Builder`] that can be used to configure a task prior to
/// spawning it on this `JoinSet`.
///
/// # Examples
///
/// ```
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/task/join_set.rs | MIT | a7896d07f1d3093524c7a190b57570dad3767c7a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a7896d07f1d3093524c7a190b57570dad3767c7a/tokio/src/task/join_set.rs | 81 | 140 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.