Skip to content

Commit a803745

Browse files
authored
move async_executor and job_token modules into new parallel module (#923)
to make parallelization related code more organized
1 parent 4d36cfa commit a803745

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,9 @@ use std::process::{Child, Command, Stdio};
6666
use std::sync::{Arc, Mutex};
6767
use std::thread::{self, JoinHandle};
6868

69-
#[cfg(feature = "parallel")]
70-
mod async_executor;
71-
#[cfg(feature = "parallel")]
72-
mod job_token;
7369
mod os_pipe;
70+
#[cfg(feature = "parallel")]
71+
mod parallel;
7472
// These modules are all glue to support reading the MSVC version from
7573
// the registry and from COM interfaces
7674
#[cfg(windows)]
@@ -1318,7 +1316,7 @@ impl Build {
13181316
fn compile_objects(&self, objs: &[Object], print: Option<&PrintThread>) -> Result<(), Error> {
13191317
use std::cell::Cell;
13201318

1321-
use async_executor::{block_on, YieldOnce};
1319+
use parallel::async_executor::{block_on, YieldOnce};
13221320

13231321
if objs.len() <= 1 {
13241322
for obj in objs {
@@ -1330,7 +1328,7 @@ impl Build {
13301328
}
13311329

13321330
// Limit our parallelism globally with a jobserver.
1333-
let tokens = crate::job_token::JobTokenServer::new();
1331+
let tokens = parallel::job_token::JobTokenServer::new();
13341332

13351333
// When compiling objects in parallel we do a few dirty tricks to speed
13361334
// things up:
@@ -1355,7 +1353,7 @@ impl Build {
13551353
Command,
13561354
String,
13571355
KillOnDrop,
1358-
crate::job_token::JobToken,
1356+
parallel::job_token::JobToken,
13591357
)>::new());
13601358
let is_disconnected = Cell::new(false);
13611359
let has_made_progress = Cell::new(false);

src/async_executor.rs renamed to src/parallel/async_executor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(
2323
const NOOP_RAW_WAKER: RawWaker = RawWaker::new(ptr::null(), &NOOP_WAKER_VTABLE);
2424

2525
#[derive(Default)]
26-
pub(super) struct YieldOnce(bool);
26+
pub(crate) struct YieldOnce(bool);
2727

2828
impl Future for YieldOnce {
2929
type Output = ();
@@ -44,7 +44,7 @@ impl Future for YieldOnce {
4444
/// Here we use our own homebrew async executor since cc is used in the build
4545
/// script of many popular projects, pulling in additional dependencies would
4646
/// significantly slow down its compilation.
47-
pub(super) fn block_on<Fut1, Fut2>(
47+
pub(crate) fn block_on<Fut1, Fut2>(
4848
mut fut1: Fut1,
4949
mut fut2: Fut2,
5050
has_made_progress: &Cell<bool>,

src/job_token.rs renamed to src/parallel/job_token/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ use std::{mem::MaybeUninit, sync::Once};
33
use crate::Error;
44

55
#[cfg(unix)]
6-
#[path = "job_token/unix.rs"]
6+
#[path = "unix.rs"]
77
mod sys;
88

99
#[cfg(windows)]
10-
#[path = "job_token/windows.rs"]
10+
#[path = "windows.rs"]
1111
mod sys;
1212

13-
pub(super) struct JobToken();
13+
pub(crate) struct JobToken();
1414

1515
impl Drop for JobToken {
1616
fn drop(&mut self) {
@@ -21,7 +21,7 @@ impl Drop for JobToken {
2121
}
2222
}
2323

24-
pub(super) enum JobTokenServer {
24+
pub(crate) enum JobTokenServer {
2525
Inherited(inherited_jobserver::JobServer),
2626
InProcess(inprocess_jobserver::JobServer),
2727
}
File renamed without changes.
File renamed without changes.

src/parallel/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub(crate) mod async_executor;
2+
pub(crate) mod job_token;

0 commit comments

Comments
 (0)