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/tests/task.rs:2 | impl Drop for AssertDrop {
fn drop(&mut self) {
self.is_dropped.store(true, Ordering::SeqCst);
}
}
// A Notified does not shut down on drop, but it is dropped once the ref-count
// hits zero.
#[test]
fn create_drop1() {
let (ad, handle) = AssertDrop::new();
let (notified, join) = unowned(
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/task.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:3 | }
#[test]
fn drop_abort_handle1() {
let (ad, handle) = AssertDrop::new();
let (notified, join) = unowned(
async {
drop(ad);
unreachable!()
},
NoopSchedule,
Id::next(),
);
let abort = join.abort_handle();
drop(join);
handle.assert_not_dropp... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/task.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:4 | }
// Shutting down through Notified works
#[test]
fn create_shutdown1() {
let (ad, handle) = AssertDrop::new();
let (notified, join) = unowned(
async {
drop(ad);
unreachable!()
},
NoopSchedule,
Id::next(),
);
drop(join);
handle.assert_not_drop... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/task.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:5 | task.run();
}
#[test]
fn schedule() {
with(|rt| {
rt.spawn(async {
crate::task::yield_now().await;
});
assert_eq!(2, rt.tick());
rt.shutdown();
})
}
#[test]
fn shutdown() {
with(|rt| {
rt.spawn(async {
loop {
crate::task::yie... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/task.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:6 | })
}
#[test]
fn spawn_during_shutdown() {
static DID_SPAWN: AtomicBool = AtomicBool::new(false);
struct SpawnOnDrop(Runtime);
impl Drop for SpawnOnDrop {
fn drop(&mut self) {
DID_SPAWN.store(true, Ordering::SeqCst);
self.0.spawn(async {});
}
}
with(|rt| {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/task.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:7 | let _reset = Reset;
let rt = Runtime(Arc::new(Inner {
owned: OwnedTasks::new(),
core: TryLock::new(Core {
queue: VecDeque::new(),
}),
}));
*CURRENT.try_lock().unwrap() = Some(rt.clone());
f(rt)
}
#[derive(Clone)]
struct Runtime(Arc<Inner>);
struct Inner {
core... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/task.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:8 | handle
}
fn tick(&self) -> usize {
self.tick_max(usize::MAX)
}
fn tick_max(&self, max: usize) -> usize {
let mut n = 0;
while !self.is_empty() && n < max {
let task = self.next_task();
n += 1;
let task = self.0.owned.assert_owner(task);
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/task.rs | 281 | 332 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:9 | }
}
impl Schedule for Runtime {
fn release(&self, task: &Task<Self>) -> Option<Task<Self>> {
self.0.owned.remove(task)
}
fn schedule(&self, task: task::Notified<Self>) {
self.0.core.try_lock().unwrap().queue.push_back(task);
}
} | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e14ca72e68fbfa04f12408ed916bf5f857dfa232 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e14ca72e68fbfa04f12408ed916bf5f857dfa232/tokio/src/runtime/tests/task.rs | 321 | 332 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:1 | use crate::runtime::blocking::NoopSchedule;
use crate::runtime::task::{self, unowned, Id, JoinHandle, OwnedTasks, Schedule, Task};
use crate::util::TryLock;
use std::collections::VecDeque;
use std::future::Future;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
struct AssertDropHandle {
is_drop... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1d3f12304e29dbb8fe3ef4089d01d5acb9edaae1/tokio/src/runtime/tests/task.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:1 | use crate::runtime::blocking::NoopSchedule;
use crate::runtime::task::{self, unowned, JoinHandle, OwnedTasks, Schedule, Task};
use crate::util::TryLock;
use std::collections::VecDeque;
use std::future::Future;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
struct AssertDropHandle {
is_dropped:... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:2 | impl Drop for AssertDrop {
fn drop(&mut self) {
self.is_dropped.store(true, Ordering::SeqCst);
}
}
// A Notified does not shut down on drop, but it is dropped once the ref-count
// hits zero.
#[test]
fn create_drop1() {
let (ad, handle) = AssertDrop::new();
let (notified, join) = unowned(
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:3 | #[test]
fn drop_abort_handle1() {
let (ad, handle) = AssertDrop::new();
let (notified, join) = unowned(
async {
drop(ad);
unreachable!()
},
NoopSchedule,
);
let abort = join.abort_handle();
drop(join);
handle.assert_not_dropped();
drop(notified... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:4 | fn create_shutdown1() {
let (ad, handle) = AssertDrop::new();
let (notified, join) = unowned(
async {
drop(ad);
unreachable!()
},
NoopSchedule,
);
drop(join);
handle.assert_not_dropped();
notified.shutdown();
handle.assert_dropped();
}
#[test]... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:5 | rt.spawn(async {
crate::task::yield_now().await;
});
assert_eq!(2, rt.tick());
rt.shutdown();
})
}
#[test]
fn shutdown() {
with(|rt| {
rt.spawn(async {
loop {
crate::task::yield_now().await;
}
});
rt.tick_max(... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:6 | struct SpawnOnDrop(Runtime);
impl Drop for SpawnOnDrop {
fn drop(&mut self) {
DID_SPAWN.store(true, Ordering::SeqCst);
self.0.spawn(async {});
}
}
with(|rt| {
let rt2 = rt.clone();
rt.spawn(async move {
let _spawn_on_drop = SpawnOnDrop(rt2... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:7 | queue: VecDeque::new(),
}),
}));
*CURRENT.try_lock().unwrap() = Some(rt.clone());
f(rt)
}
#[derive(Clone)]
struct Runtime(Arc<Inner>);
struct Inner {
core: TryLock<Core>,
owned: OwnedTasks<Runtime>,
}
struct Core {
queue: VecDeque<task::Notified<Runtime>>,
}
static CURRENT: TryLock<... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:8 | fn tick_max(&self, max: usize) -> usize {
let mut n = 0;
while !self.is_empty() && n < max {
let task = self.next_task();
n += 1;
let task = self.0.owned.assert_owner(task);
task.run();
}
n
}
fn is_empty(&self) -> bool {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task.rs | 281 | 326 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:2 | impl Drop for AssertDrop {
fn drop(&mut self) {
self.is_dropped.store(true, Ordering::SeqCst);
}
}
// A Notified does not shut down on drop, but it is dropped once the ref-count
// hits zero.
#[test]
fn create_drop1() {
let (ad, handle) = AssertDrop::new();
let (notified, join) = unowned(
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 4152918a39214d22e4b9e8d2148641b38b4f1c6e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4152918a39214d22e4b9e8d2148641b38b4f1c6e/tokio/src/runtime/tests/task.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:3 | // Shutting down through Notified works
#[test]
fn create_shutdown1() {
let (ad, handle) = AssertDrop::new();
let (notified, join) = unowned(
async {
drop(ad);
unreachable!()
},
NoopSchedule,
);
drop(join);
handle.assert_not_dropped();
notified.shu... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 4152918a39214d22e4b9e8d2148641b38b4f1c6e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4152918a39214d22e4b9e8d2148641b38b4f1c6e/tokio/src/runtime/tests/task.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:4 | fn schedule() {
with(|rt| {
rt.spawn(async {
crate::task::yield_now().await;
});
assert_eq!(2, rt.tick());
rt.shutdown();
})
}
#[test]
fn shutdown() {
with(|rt| {
rt.spawn(async {
loop {
crate::task::yield_now().await;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 4152918a39214d22e4b9e8d2148641b38b4f1c6e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4152918a39214d22e4b9e8d2148641b38b4f1c6e/tokio/src/runtime/tests/task.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:5 | fn spawn_during_shutdown() {
static DID_SPAWN: AtomicBool = AtomicBool::new(false);
struct SpawnOnDrop(Runtime);
impl Drop for SpawnOnDrop {
fn drop(&mut self) {
DID_SPAWN.store(true, Ordering::SeqCst);
self.0.spawn(async {});
}
}
with(|rt| {
let rt2... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 4152918a39214d22e4b9e8d2148641b38b4f1c6e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4152918a39214d22e4b9e8d2148641b38b4f1c6e/tokio/src/runtime/tests/task.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:6 | owned: OwnedTasks::new(),
core: TryLock::new(Core {
queue: VecDeque::new(),
}),
}));
*CURRENT.try_lock().unwrap() = Some(rt.clone());
f(rt)
}
#[derive(Clone)]
struct Runtime(Arc<Inner>);
struct Inner {
core: TryLock<Core>,
owned: OwnedTasks<Runtime>,
}
struct Core {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 4152918a39214d22e4b9e8d2148641b38b4f1c6e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4152918a39214d22e4b9e8d2148641b38b4f1c6e/tokio/src/runtime/tests/task.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:7 | self.tick_max(usize::MAX)
}
fn tick_max(&self, max: usize) -> usize {
let mut n = 0;
while !self.is_empty() && n < max {
let task = self.next_task();
n += 1;
let task = self.0.owned.assert_owner(task);
task.run();
}
n
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 4152918a39214d22e4b9e8d2148641b38b4f1c6e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4152918a39214d22e4b9e8d2148641b38b4f1c6e/tokio/src/runtime/tests/task.rs | 241 | 288 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:3 | // Shutting down through Notified works
#[test]
fn create_shutdown1() {
let (ad, handle) = AssertDrop::new();
let (notified, join) = unowned(
async {
drop(ad);
unreachable!()
},
NoopSchedule,
);
drop(join);
handle.assert_not_dropped();
notified.shu... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/tests/task.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:4 | assert_eq!(2, rt.tick());
rt.shutdown();
})
}
#[test]
fn shutdown() {
with(|rt| {
rt.spawn(async {
loop {
crate::task::yield_now().await;
}
});
rt.tick_max(1);
rt.shutdown();
})
}
#[test]
fn shutdown_immediately() {
with... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/tests/task.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:5 | DID_SPAWN.store(true, Ordering::SeqCst);
self.0.spawn(async {});
}
}
with(|rt| {
let rt2 = rt.clone();
rt.spawn(async move {
let _spawn_on_drop = SpawnOnDrop(rt2);
loop {
crate::task::yield_now().await;
}
});
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/tests/task.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:6 | *CURRENT.try_lock().unwrap() = Some(rt.clone());
f(rt)
}
#[derive(Clone)]
struct Runtime(Arc<Inner>);
struct Inner {
core: TryLock<Core>,
owned: OwnedTasks<Runtime>,
}
struct Core {
queue: VecDeque<task::Notified<Runtime>>,
}
static CURRENT: TryLock<Option<Runtime>> = TryLock::new(None);
impl Runti... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/tests/task.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:7 | while !self.is_empty() && n < max {
let task = self.next_task();
n += 1;
let task = self.0.owned.assert_owner(task);
task.run();
}
n
}
fn is_empty(&self) -> bool {
self.0.core.try_lock().unwrap().queue.is_empty()
}
fn next_task(&... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | b501f25202aba8f50c1ded4204f0129939fabc79 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b501f25202aba8f50c1ded4204f0129939fabc79/tokio/src/runtime/tests/task.rs | 241 | 282 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:7 | while !self.is_empty() && n < max {
let task = self.next_task();
n += 1;
let task = self.0.owned.assert_owner(task);
task.run();
}
n
}
fn is_empty(&self) -> bool {
self.0.core.try_lock().unwrap().queue.is_empty()
}
fn next_task(&... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | f2a06bff1be147a72d40cb01d8bb621fbdc242fc | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f2a06bff1be147a72d40cb01d8bb621fbdc242fc/tokio/src/runtime/tests/task.rs | 241 | 285 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:6 | *CURRENT.try_lock().unwrap() = Some(rt.clone());
f(rt)
}
#[derive(Clone)]
struct Runtime(Arc<Inner>);
struct Inner {
core: TryLock<Core>,
owned: OwnedTasks<Runtime>,
}
struct Core {
queue: VecDeque<task::Notified<Runtime>>,
}
static CURRENT: TryLock<Option<Runtime>> = TryLock::new(None);
impl Runti... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 2087f3e0ebb08d633d59c5f964b3901e68b3c038 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/runtime/tests/task.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:7 | while !self.is_empty() && n < max {
let task = self.next_task();
n += 1;
task.run();
}
n
}
fn is_empty(&self) -> bool {
self.0.core.try_lock().unwrap().queue.is_empty()
}
fn next_task(&self) -> task::Notified<Runtime> {
self.0.core.t... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 2087f3e0ebb08d633d59c5f964b3901e68b3c038 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2087f3e0ebb08d633d59c5f964b3901e68b3c038/tokio/src/runtime/tests/task.rs | 241 | 285 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:1 | use crate::runtime::task::{self, OwnedTasks, Schedule, Task};
use crate::util::TryLock;
use std::collections::VecDeque;
use std::sync::Arc;
#[test]
fn create_drop() {
let _ = super::joinable::<_, Runtime>(async { unreachable!() });
}
#[test]
fn schedule() {
with(|rt| {
let (task, _) = super::joinable... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e2589a0e401e27457618920e66caa0f14e9a69ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/runtime/tests/task.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:2 | fn with(f: impl FnOnce(Runtime)) {
struct Reset;
impl Drop for Reset {
fn drop(&mut self) {
let _rt = CURRENT.try_lock().unwrap().take();
}
}
let _reset = Reset;
let rt = Runtime(Arc::new(Inner {
owned: OwnedTasks::new(),
core: TryLock::new(Core {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e2589a0e401e27457618920e66caa0f14e9a69ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/runtime/tests/task.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:3 | fn tick_max(&self, max: usize) -> usize {
let mut n = 0;
while !self.is_empty() && n < max {
let task = self.next_task();
n += 1;
task.run();
}
n
}
fn is_empty(&self) -> bool {
self.0.core.try_lock().unwrap().queue.is_empty()
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e2589a0e401e27457618920e66caa0f14e9a69ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/runtime/tests/task.rs | 81 | 134 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:4 | let rt = CURRENT.try_lock().unwrap().as_ref().unwrap().clone();
rt.0.owned.push_front(task);
rt
}
fn release(&self, task: &Task<Self>) -> Option<Task<Self>> {
// safety: copying worker.rs
unsafe { self.0.owned.remove(task) }
}
fn schedule(&self, task: task::Notified<Sel... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | e2589a0e401e27457618920e66caa0f14e9a69ad | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e2589a0e401e27457618920e66caa0f14e9a69ad/tokio/src/runtime/tests/task.rs | 121 | 134 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:1 | use crate::runtime::task::{self, Schedule, Task};
use crate::util::linked_list::{Link, LinkedList};
use crate::util::TryLock;
use std::collections::VecDeque;
use std::sync::Arc;
#[test]
fn create_drop() {
let _ = super::joinable::<_, Runtime>(async { unreachable!() });
}
#[test]
fn schedule() {
with(|rt| {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 90e1935c486417ec64507b26ff4bf80a3dfb19e2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90e1935c486417ec64507b26ff4bf80a3dfb19e2/tokio/src/runtime/tests/task.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:2 | fn with(f: impl FnOnce(Runtime)) {
struct Reset;
impl Drop for Reset {
fn drop(&mut self) {
let _rt = CURRENT.try_lock().unwrap().take();
}
}
let _reset = Reset;
let rt = Runtime(Arc::new(Inner {
released: task::TransferStack::new(),
core: TryLock::new(... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 90e1935c486417ec64507b26ff4bf80a3dfb19e2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90e1935c486417ec64507b26ff4bf80a3dfb19e2/tokio/src/runtime/tests/task.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:3 | fn tick(&self) -> usize {
self.tick_max(usize::MAX)
}
fn tick_max(&self, max: usize) -> usize {
let mut n = 0;
while !self.is_empty() && n < max {
let task = self.next_task();
n += 1;
task.run();
}
self.0.maintenance();
n
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 90e1935c486417ec64507b26ff4bf80a3dfb19e2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90e1935c486417ec64507b26ff4bf80a3dfb19e2/tokio/src/runtime/tests/task.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:4 | self.0.maintenance();
}
}
}
impl Inner {
fn maintenance(&self) {
use std::mem::ManuallyDrop;
for task in self.released.drain() {
let task = ManuallyDrop::new(task);
// safety: see worker.rs
unsafe {
let ptr = task.header().into();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | 90e1935c486417ec64507b26ff4bf80a3dfb19e2 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/90e1935c486417ec64507b26ff4bf80a3dfb19e2/tokio/src/runtime/tests/task.rs | 121 | 159 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:1 | use crate::runtime::task::{self, Schedule, Task};
use crate::util::linked_list::{Link, LinkedList};
use crate::util::TryLock;
use std::collections::VecDeque;
use std::sync::Arc;
#[test]
fn create_drop() {
let _ = task::joinable::<_, Runtime>(async { unreachable!() });
}
#[test]
fn schedule() {
with(|rt| {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | f3ed064a269fd72711e40121dad1a9fd9f16bdc0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/f3ed064a269fd72711e40121dad1a9fd9f16bdc0/tokio/src/runtime/tests/task.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:2 | fn with(f: impl FnOnce(Runtime)) {
struct Reset;
impl Drop for Reset {
fn drop(&mut self) {
let _rt = CURRENT.try_lock().unwrap().take();
}
}
let _reset = Reset;
let rt = Runtime(Arc::new(Inner {
released: task::TransferStack::new(),
core: TryLock::new(... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | c9f5bc29158a6f3a786e9d67df8da31524e8a9c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/runtime/tests/task.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:3 | fn tick(&self) -> usize {
self.tick_max(usize::max_value())
}
fn tick_max(&self, max: usize) -> usize {
let mut n = 0;
while !self.is_empty() && n < max {
let task = self.next_task();
n += 1;
task.run();
}
self.0.maintenance();
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | c9f5bc29158a6f3a786e9d67df8da31524e8a9c3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c9f5bc29158a6f3a786e9d67df8da31524e8a9c3/tokio/src/runtime/tests/task.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:1 | use crate::runtime::task::{self, Schedule, Task};
use crate::util::linked_list::LinkedList;
use crate::util::TryLock;
use std::collections::VecDeque;
use std::sync::Arc;
#[test]
fn create_drop() {
let _ = task::joinable::<_, Runtime>(async { unreachable!() });
}
#[test]
fn schedule() {
with(|rt| {
le... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/tests/task.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/task.rs:2 | fn with(f: impl FnOnce(Runtime)) {
struct Reset;
impl Drop for Reset {
fn drop(&mut self) {
let _rt = CURRENT.try_lock().unwrap().take();
}
}
let _reset = Reset;
let rt = Runtime(Arc::new(Inner {
released: task::TransferStack::new(),
core: TryLock::new(... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/tests/task.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:1 | use std::fmt;
use std::future::Future;
use std::panic;
use std::pin::Pin;
use std::task::{Context, Poll};
use crate::runtime::task::AbortHandle;
use crate::runtime::Builder;
use crate::sync::oneshot;
use crate::task::JoinHandle;
use futures::future::FutureExt;
// Enums for each option in the combinations being teste... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:2 | Polled,
NotPolled,
}
#[allow(clippy::enum_variant_names)] // we aren't using glob imports
#[derive(Copy, Clone, Debug, PartialEq)]
enum CombiJoinHandle {
DropImmediately = 1,
DropFirstPoll = 2,
DropAfterNoConsume = 3,
DropAfterConsume = 4,
}
#[derive(Copy, Clone, Debug, PartialEq)]
enum CombiAbort {... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:3 | let task = [
CombiTask::NoPanic,
CombiTask::PanicOnRun,
CombiTask::PanicOnDrop,
CombiTask::PanicOnRunAndDrop,
];
let output = [CombiOutput::NoPanic, CombiOutput::PanicOnDrop];
let ji = [CombiJoinInterest::Polled, CombiJoinInterest::NotPolled];
let jh = [
CombiJoin... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:4 | rt,
ls,
task,
output,
ji,
jh,
ah,
abort,... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:5 | output: CombiOutput,
ji: CombiJoinInterest,
jh: CombiJoinHandle,
ah: Option<CombiJoinHandle>,
abort: CombiAbort,
abort_src: CombiAbortSource,
) {
match (abort_src, ah) {
(CombiAbortSource::JoinHandle, _) if (jh as usize) < (abort as usize) => {
// join handle dropped prior to... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:6 | // A runtime optionally with a LocalSet
struct Rt {
rt: crate::runtime::Runtime,
ls: Option<crate::task::LocalSet>,
}
impl Rt {
fn new(rt: CombiRuntime, ls: CombiLocalSet) -> Self {
let rt = match rt {
CombiRuntime::CurrentThread => Builder::new_current_th... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:7 | match &self.ls {
Some(ls) => ls.spawn_local(task),
None => self.rt.spawn(task),
}
}
}
// The type used for the output of the future
struct Output {
panic_on_drop: bool,
on_drop: Option<oneshot::Sender<()>>,
}
impl Output {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:8 | }
}
impl<F> Drop for FutWrapper<F> {
fn drop(&mut self) {
let _: Result<(), ()> = self.on_drop.take().unwrap().send(());
if self.panic_on_drop {
panic!("Panicking in FutWrapper");
}
}
}
// The channels passed to the task
struct Sig... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:9 | let rt = Rt::new(rt, ls);
let (on_first_poll, wait_first_poll) = oneshot::channel();
let (on_complete, wait_complete) = oneshot::channel();
let (on_future_drop, wait_future_drop) = oneshot::channel();
let (on_output_drop, wait_output_drop) = oneshot::channel();
let signal = Signals {
on_fir... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:10 | match abort_src {
CombiAbortSource::AbortHandle => abort_handle.take().unwrap().abort(),
CombiAbortSource::JoinHandle => join_handle.unwrap().abort(),
}
};
if abort == CombiAbort::AbortedImmediately {
do_abort(&mut abort_handle, handle.as_mut());
aborted = true;
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:11 | "The future should always be dropped."
);
if abort == CombiAbort::AbortedAfterFinish {
// Don't set aborted to true here as the task already finished
do_abort(&mut abort_handle, handle.as_mut());
}
if jh == CombiJoinHandle::DropAfterNoConsume {
if ah == Some(CombiJoinHandle::Dro... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:12 | }
}
}
// Check whether we drop after consuming the output
if jh == CombiJoinHandle::DropAfterConsume {
// Using as_mut() to not immediately drop the handle
let result = rt.block_on(handle.as_mut().unwrap());
match result {
Ok(mut output) => {
// ... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/tests/task_combinations.rs | 441 | 488 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:2 | Polled,
NotPolled,
}
#[allow(clippy::enum_variant_names)] // we aren't using glob imports
#[derive(Copy, Clone, Debug, PartialEq)]
enum CombiJoinHandle {
DropImmediately = 1,
DropFirstPoll = 2,
DropAfterNoConsume = 3,
DropAfterConsume = 4,
}
#[derive(Copy, Clone, Debug, PartialEq)]
enum CombiAbort {... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | d8a4a5f24bfc5012071eec4e501bb4a58a1181d6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d8a4a5f24bfc5012071eec4e501bb4a58a1181d6/tokio/src/runtime/tests/task_combinations.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:2 | Polled,
NotPolled,
}
#[allow(clippy::enum_variant_names)] // we aren't using glob imports
#[derive(Copy, Clone, Debug, PartialEq)]
enum CombiJoinHandle {
DropImmediately = 1,
DropFirstPoll = 2,
DropAfterNoConsume = 3,
DropAfterConsume = 4,
}
#[derive(Copy, Clone, Debug, PartialEq)]
enum CombiAbort {... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:3 | CombiTask::NoPanic,
CombiTask::PanicOnRun,
CombiTask::PanicOnDrop,
CombiTask::PanicOnRunAndDrop,
];
let output = [CombiOutput::NoPanic, CombiOutput::PanicOnDrop];
let ji = [CombiJoinInterest::Polled, CombiJoinInterest::NotPolled];
let jh = [
CombiJoinHandle::DropImmediate... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:4 | ls,
task,
output,
ji,
jh,
ah,
abort,
Com... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:5 | ji: CombiJoinInterest,
jh: CombiJoinHandle,
ah: Option<CombiJoinHandle>,
abort: CombiAbort,
abort_src: CombiAbortSource,
) {
match (abort_src, ah) {
(CombiAbortSource::JoinHandle, _) if (jh as usize) < (abort as usize) => {
// join handle dropped prior to abort
return... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:6 | struct Rt {
rt: crate::runtime::Runtime,
ls: Option<crate::task::LocalSet>,
}
impl Rt {
fn new(rt: CombiRuntime, ls: CombiLocalSet) -> Self {
let rt = match rt {
CombiRuntime::CurrentThread => Builder::new_current_thread().build().unwrap(),
Com... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:7 | Some(ls) => ls.spawn_local(task),
None => self.rt.spawn(task),
}
}
}
// The type used for the output of the future
struct Output {
panic_on_drop: bool,
on_drop: Option<oneshot::Sender<()>>,
}
impl Output {
fn disarm(&mut self) {
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:8 | }
impl<F> Drop for FutWrapper<F> {
fn drop(&mut self) {
let _: Result<(), ()> = self.on_drop.take().unwrap().send(());
if self.panic_on_drop {
panic!("Panicking in FutWrapper");
}
}
}
// The channels passed to the task
struct Signals {... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:9 | let (on_first_poll, wait_first_poll) = oneshot::channel();
let (on_complete, wait_complete) = oneshot::channel();
let (on_future_drop, wait_future_drop) = oneshot::channel();
let (on_output_drop, wait_output_drop) = oneshot::channel();
let signal = Signals {
on_first_poll: Some(on_first_poll),
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:10 | CombiAbortSource::AbortHandle => abort_handle.take().unwrap().abort(),
CombiAbortSource::JoinHandle => join_handle.unwrap().abort(),
}
};
if abort == CombiAbort::AbortedImmediately {
do_abort(&mut abort_handle, handle.as_mut());
aborted = true;
}
if jh == CombiJoinHa... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:11 | );
if abort == CombiAbort::AbortedAfterFinish {
// Don't set aborted to true here as the task already finished
do_abort(&mut abort_handle, handle.as_mut());
}
if jh == CombiJoinHandle::DropAfterNoConsume {
if ah == Some(CombiJoinHandle::DropAfterNoConsume) {
drop(handle.... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:12 | }
}
// Check whether we drop after consuming the output
if jh == CombiJoinHandle::DropAfterConsume {
// Using as_mut() to not immediately drop the handle
let result = rt.block_on(handle.as_mut().unwrap());
match result {
Ok(mut output) => {
// Don't pani... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 57e08e714754420f8b3d8ffe863549d8acf761d0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/57e08e714754420f8b3d8ffe863549d8acf761d0/tokio/src/runtime/tests/task_combinations.rs | 441 | 487 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:1 | use std::future::Future;
use std::panic;
use std::pin::Pin;
use std::task::{Context, Poll};
use crate::runtime::task::AbortHandle;
use crate::runtime::Builder;
use crate::sync::oneshot;
use crate::task::JoinHandle;
use futures::future::FutureExt;
// Enums for each option in the combinations being tested
#[derive(Co... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:2 | NotPolled,
}
#[allow(clippy::enum_variant_names)] // we aren't using glob imports
#[derive(Copy, Clone, Debug, PartialEq)]
enum CombiJoinHandle {
DropImmediately = 1,
DropFirstPoll = 2,
DropAfterNoConsume = 3,
DropAfterConsume = 4,
}
#[derive(Copy, Clone, Debug, PartialEq)]
enum CombiAbort {
NotAbor... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:3 | CombiTask::PanicOnRun,
CombiTask::PanicOnDrop,
CombiTask::PanicOnRunAndDrop,
];
let output = [CombiOutput::NoPanic, CombiOutput::PanicOnDrop];
let ji = [CombiJoinInterest::Polled, CombiJoinInterest::NotPolled];
let jh = [
CombiJoinHandle::DropImmediately,
CombiJoinHandle:... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:4 | task,
output,
ji,
jh,
ah,
abort,
CombiAbortSource::JoinHandle,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:5 | abort: CombiAbort,
abort_src: CombiAbortSource,
) {
match (abort_src, ah) {
(CombiAbortSource::JoinHandle, _) if (jh as usize) < (abort as usize) => {
// join handle dropped prior to abort
return;
}
(CombiAbortSource::AbortHandle, Some(_)) => {
// abor... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:6 | .unwrap(),
CombiRuntime::Multi2 => Builder::new_multi_thread()
.worker_threads(2)
.build()
.unwrap(),
};
let ls = match ls {
CombiLocalSet::Yes => Some(crate::task::LocalSet::new()),
Comb... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:7 | impl Output {
fn disarm(&mut self) {
self.panic_on_drop = false;
}
}
impl Drop for Output {
fn drop(&mut self) {
let _ = self.on_drop.take().unwrap().send(());
if self.panic_on_drop {
panic!("Panicking in Output");
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:8 | struct Signals {
on_first_poll: Option<oneshot::Sender<()>>,
wait_complete: Option<oneshot::Receiver<()>>,
on_output_drop: Option<oneshot::Sender<()>>,
}
// The task we will spawn
async fn my_task(mut signal: Signals, task: CombiTask, out: CombiOutput) -> Output {
// Signal ... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:9 | // === Spawn task ===
let mut handle = Some(rt.spawn(FutWrapper {
inner: my_task(signal, task, output),
on_drop: Some(on_future_drop),
panic_on_drop: task == CombiTask::PanicOnDrop || task == CombiTask::PanicOnRunAndDrop,
}));
// Keep track of whether the task has been killed with a... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:10 | }
// === Wait for first poll ===
let got_polled = rt.block_on(wait_first_poll).is_ok();
if !got_polled {
// it's possible that we are aborted but still got polled
assert!(
aborted,
"Task completed without ever being polled but was not aborted."
);
}
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:11 | //
// (But it might race and still hold a ref-count)
let panic = panic::catch_unwind(panic::AssertUnwindSafe(|| {
drop(abort_handle.take().unwrap());
}));
if panic.is_err() {
assert!(
(output == CombiOutput::PanicOnDrop)... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:12 | output.disarm();
assert!(!aborted, "Task was aborted but returned output");
}
Err(err) if err.is_cancelled() => assert!(aborted, "Cancelled output but not aborted"),
Err(err) if err.is_panic() => {
assert!(
(task == CombiTask::Panic... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | 8e0e56fdf23da0ad807c78ac57a19db939666253 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8e0e56fdf23da0ad807c78ac57a19db939666253/tokio/src/runtime/tests/task_combinations.rs | 441 | 476 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:1 | use std::future::Future;
use std::panic;
use std::pin::Pin;
use std::task::{Context, Poll};
use crate::runtime::Builder;
use crate::sync::oneshot;
use crate::task::JoinHandle;
use futures::future::FutureExt;
// Enums for each option in the combinations being tested
#[derive(Copy, Clone, Debug, PartialEq)]
enum Comb... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | ced7992f6555d884cac452d177b094eb44a58a29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ced7992f6555d884cac452d177b094eb44a58a29/tokio/src/runtime/tests/task_combinations.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:2 | }
#[allow(clippy::enum_variant_names)] // we aren't using glob imports
#[derive(Copy, Clone, Debug, PartialEq)]
enum CombiJoinHandle {
DropImmediately = 1,
DropFirstPoll = 2,
DropAfterNoConsume = 3,
DropAfterConsume = 4,
}
#[derive(Copy, Clone, Debug, PartialEq)]
enum CombiAbort {
NotAborted = 0,
... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | ced7992f6555d884cac452d177b094eb44a58a29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ced7992f6555d884cac452d177b094eb44a58a29/tokio/src/runtime/tests/task_combinations.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:3 | CombiJoinHandle::DropImmediately,
CombiJoinHandle::DropFirstPoll,
CombiJoinHandle::DropAfterNoConsume,
CombiJoinHandle::DropAfterConsume,
];
let abort = [
CombiAbort::NotAborted,
CombiAbort::AbortedImmediately,
CombiAbort::AbortedFirstPoll,
CombiAbort::Abo... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | ced7992f6555d884cac452d177b094eb44a58a29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ced7992f6555d884cac452d177b094eb44a58a29/tokio/src/runtime/tests/task_combinations.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:4 | // drop before abort not possible
return;
}
if (task == CombiTask::PanicOnDrop) && (output == CombiOutput::PanicOnDrop) {
// this causes double panic
return;
}
if (task == CombiTask::PanicOnRunAndDrop) && (abort != CombiAbort::AbortedImmediately) {
// this causes double p... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | ced7992f6555d884cac452d177b094eb44a58a29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ced7992f6555d884cac452d177b094eb44a58a29/tokio/src/runtime/tests/task_combinations.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:5 | fn block_on<T>(&self, task: T) -> T::Output
where
T: Future,
{
match &self.ls {
Some(ls) => ls.block_on(&self.rt, task),
None => self.rt.block_on(task),
}
}
fn spawn<T>(&self, task: T) -> JoinHandle<T::Output>
wh... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | ced7992f6555d884cac452d177b094eb44a58a29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ced7992f6555d884cac452d177b094eb44a58a29/tokio/src/runtime/tests/task_combinations.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:6 | // A wrapper around the future that is spawned
struct FutWrapper<F> {
inner: F,
on_drop: Option<oneshot::Sender<()>>,
panic_on_drop: bool,
}
impl<F: Future> Future for FutWrapper<F> {
type Output = F::Output;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | ced7992f6555d884cac452d177b094eb44a58a29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ced7992f6555d884cac452d177b094eb44a58a29/tokio/src/runtime/tests/task_combinations.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:7 | // If the task gets past wait_complete without yielding, then aborts
// may not be caught without this yield_now.
crate::task::yield_now().await;
if task == CombiTask::PanicOnRun || task == CombiTask::PanicOnRunAndDrop {
panic!("Panicking in my_task on {:?}", std::thread::current().... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | ced7992f6555d884cac452d177b094eb44a58a29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ced7992f6555d884cac452d177b094eb44a58a29/tokio/src/runtime/tests/task_combinations.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:8 | "Polling handle succeeded"
);
}
if abort == CombiAbort::AbortedImmediately {
handle.as_mut().unwrap().abort();
aborted = true;
}
if jh == CombiJoinHandle::DropImmediately {
drop(handle.take().unwrap());
}
// === Wait for first poll ===
let got_polled = rt.bl... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | ced7992f6555d884cac452d177b094eb44a58a29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ced7992f6555d884cac452d177b094eb44a58a29/tokio/src/runtime/tests/task_combinations.rs | 281 | 340 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:9 | handle.as_mut().unwrap().abort();
}
if jh == CombiJoinHandle::DropAfterNoConsume {
// The runtime will usually have dropped every ref-count at this point,
// in which case dropping the JoinHandle drops the output.
//
// (But it might race and still hold a ref-count)
let p... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | ced7992f6555d884cac452d177b094eb44a58a29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ced7992f6555d884cac452d177b094eb44a58a29/tokio/src/runtime/tests/task_combinations.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/runtime/tests/task_combinations.rs:10 | }
_ => unreachable!(),
}
let handle = handle.take().unwrap();
if abort == CombiAbort::AbortedAfterConsumeOutput {
handle.abort();
}
drop(handle);
}
// The output should have been dropped now. Check whether the output
// object was created at ... | rust | rust | testsuite | tokio-rs/tokio | tokio/src/runtime/tests/task_combinations.rs | MIT | ced7992f6555d884cac452d177b094eb44a58a29 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ced7992f6555d884cac452d177b094eb44a58a29/tokio/src/runtime/tests/task_combinations.rs | 361 | 380 |
tokio-rs/tokio:tokio/src/runtime/thread_id.rs:1 | use std::num::NonZeroU64;
#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)]
pub(crate) struct ThreadId(NonZeroU64);
impl ThreadId {
pub(crate) fn next() -> Self {
use crate::loom::sync::atomic::{AtomicU64, Ordering::Relaxed};
#[cfg(all(test, loom))]
crate::loom::lazy_static! {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_id.rs | MIT | c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/runtime/thread_id.rs | 1 | 37 |
tokio-rs/tokio:tokio/src/runtime/thread_id.rs:1 | use std::num::NonZeroU64;
#[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)]
pub(crate) struct ThreadId(NonZeroU64);
impl ThreadId {
pub(crate) fn next() -> Self {
use crate::loom::sync::atomic::{Ordering::Relaxed, StaticAtomicU64};
static NEXT_ID: StaticAtomicU64 = StaticAtomicU64::new(0);
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_id.rs | MIT | c6552c5680fa14105547cfbbc26b26d67197b64e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/c6552c5680fa14105547cfbbc26b26d67197b64e/tokio/src/runtime/thread_id.rs | 1 | 31 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/atomic_cell.rs:1 | use crate::loom::sync::atomic::AtomicPtr;
use std::ptr;
use std::sync::atomic::Ordering::AcqRel;
pub(super) struct AtomicCell<T> {
data: AtomicPtr<T>,
}
unsafe impl<T: Send> Send for AtomicCell<T> {}
unsafe impl<T: Send> Sync for AtomicCell<T> {}
impl<T> AtomicCell<T> {
pub(super) fn new(data: Option<Box<T>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/atomic_cell.rs | MIT | 8880222036f37c6204c8466f25e828447f16dacb | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8880222036f37c6204c8466f25e828447f16dacb/tokio/src/runtime/thread_pool/atomic_cell.rs | 1 | 51 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/atomic_cell.rs:1 | use crate::loom::sync::atomic::AtomicPtr;
use std::ptr;
use std::sync::atomic::Ordering::AcqRel;
pub(super) struct AtomicCell<T> {
data: AtomicPtr<T>,
}
unsafe impl<T: Send> Send for AtomicCell<T> {}
unsafe impl<T: Send> Sync for AtomicCell<T> {}
impl<T> AtomicCell<T> {
pub(super) fn new(data: Option<Box<T>... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/atomic_cell.rs | MIT | a78b1c65ccfb9692ca5d3ed8ddde934f40091d83 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/a78b1c65ccfb9692ca5d3ed8ddde934f40091d83/tokio/src/runtime/thread_pool/atomic_cell.rs | 1 | 52 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/current.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::thread_pool::{slice, Owned};
use std::cell::Cell;
use std::ptr;
/// Tracks the current worker
#[derive(Debug)]
pub(super) struct Current {
inner: Inner,
}
#[derive(Debug, Copy, Clone)]
struct Inner {
// thread-local variables cannot track generics. However, the... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/current.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/runtime/thread_pool/current.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/current.rs:2 | workers: pool.shared() as *const _ as *const (),
idx: index,
});
let _g = Guard(cell);
f()
})
}
pub(super) fn clear() {
CURRENT_WORKER.with(|cell| cell.set(Inner::new()))
}
pub(super) fn get<F, R>(f: F) -> R
where
F: FnOnce(&Current) -> R,
{
CURRENT_WORKER.with(|c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/current.rs | MIT | 8546ff826db8dba1e39b4119ad909fb6cab2492a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/8546ff826db8dba1e39b4119ad909fb6cab2492a/tokio/src/runtime/thread_pool/current.rs | 41 | 84 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/current.rs:1 | use crate::loom::sync::Arc;
use crate::runtime::park::Unpark;
use crate::runtime::thread_pool::{slice, Owned};
use std::cell::Cell;
use std::ptr;
/// Tracks the current worker
#[derive(Debug)]
pub(super) struct Current {
inner: Inner,
}
#[derive(Debug, Copy, Clone)]
struct Inner {
// thread-local variables c... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/current.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/current.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/current.rs:2 | cell.set(Inner {
workers: pool.shared() as *const _ as *const (),
idx: index,
});
let _g = Guard(cell);
f()
})
}
pub(super) fn clear() {
CURRENT_WORKER.with(|cell| cell.set(Inner::new()))
}
pub(super) fn get<F, R>(f: F) -> R
where
F: FnOnce(&Current) -> R,... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/current.rs | MIT | 27e5b41067d01c0c9fac230c5addb58034201a63 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/27e5b41067d01c0c9fac230c5addb58034201a63/tokio/src/runtime/thread_pool/current.rs | 41 | 89 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/idle.rs:1 | //! Coordinates idling workers
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Mutex;
use std::fmt;
use std::sync::atomic::Ordering::{self, SeqCst};
pub(super) struct Idle {
/// Tracks both the number of searching workers and the number of unparked
/// workers.
///
/// Used as a fa... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/idle.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/idle.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/runtime/thread_pool/idle.rs:2 | /// If there are no workers actively searching, returns the index of a
/// worker currently sleeping.
pub(super) fn worker_to_notify(&self) -> Option<usize> {
// If at least one worker is spinning, work being notified will
// eventually be found. A searching thread will find **some** work and
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/runtime/thread_pool/idle.rs | MIT | 4eed411519783ef6f58cbf74f886f91142b5cfa6 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/4eed411519783ef6f58cbf74f886f91142b5cfa6/tokio/src/runtime/thread_pool/idle.rs | 41 | 100 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.