Skip to content

Commit

Permalink
rt: move park logic into runtime module (#5158)
Browse files Browse the repository at this point in the history
The runtime is the primary user of parking. Moving park into runtime
will help future cleanups around combining context entering w/ block_on
calls.
  • Loading branch information
carllerche committed Nov 2, 2022
1 parent d8ee205 commit 467adec
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 43 deletions.
2 changes: 1 addition & 1 deletion tokio/src/future/block_on.rs
Expand Up @@ -11,7 +11,7 @@ cfg_rt! {
cfg_not_rt! {
#[track_caller]
pub(crate) fn block_on<F: Future>(f: F) -> F::Output {
let mut park = crate::park::thread::CachedParkThread::new();
let mut park = crate::runtime::park::CachedParkThread::new();
park.block_on(f).unwrap()
}
}
1 change: 0 additions & 1 deletion tokio/src/lib.rs
Expand Up @@ -479,7 +479,6 @@ pub mod io;
pub mod net;

mod loom;
mod park;

cfg_process! {
pub mod process;
Expand Down
37 changes: 0 additions & 37 deletions tokio/src/park/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tokio/src/runtime/driver.rs
Expand Up @@ -4,7 +4,7 @@
// don't need to worry much about dead code with certain feature permutations.
#![cfg_attr(not(feature = "full"), allow(dead_code))]

use crate::park::thread::{ParkThread, UnparkThread};
use crate::runtime::park::{ParkThread, UnparkThread};

use std::io;
use std::time::Duration;
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/runtime/enter.rs
Expand Up @@ -146,7 +146,7 @@ cfg_rt! {
where
F: std::future::Future,
{
use crate::park::thread::CachedParkThread;
use crate::runtime::park::CachedParkThread;

let mut park = CachedParkThread::new();
park.block_on(f)
Expand All @@ -160,7 +160,7 @@ cfg_rt! {
where
F: std::future::Future,
{
use crate::park::thread::CachedParkThread;
use crate::runtime::park::CachedParkThread;
use std::task::Context;
use std::task::Poll::Ready;
use std::time::Instant;
Expand Down
2 changes: 2 additions & 0 deletions tokio/src/runtime/mod.rs
Expand Up @@ -181,6 +181,8 @@ pub(crate) mod context;

pub(crate) mod coop;

pub(crate) mod park;

mod driver;

pub(crate) mod scheduler;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tokio/src/sync/mpsc/chan.rs
Expand Up @@ -2,7 +2,7 @@ use crate::loom::cell::UnsafeCell;
use crate::loom::future::AtomicWaker;
use crate::loom::sync::atomic::AtomicUsize;
use crate::loom::sync::Arc;
use crate::park::thread::CachedParkThread;
use crate::runtime::park::CachedParkThread;
use crate::sync::mpsc::error::TryRecvError;
use crate::sync::mpsc::{bounded, list, unbounded};
use crate::sync::notify::Notify;
Expand Down

0 comments on commit 467adec

Please sign in to comment.