Skip to content

Commit 3d45841

Browse files
committed
Make jobserver initialization private in job_token mod
1 parent 52afaf1 commit 3d45841

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/job_token.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use jobserver::{Acquired, Client, HelperThread};
1+
use jobserver::{Acquired, HelperThread};
22
use std::{
33
env,
44
sync::{
@@ -47,7 +47,8 @@ pub(crate) struct JobTokenServer {
4747
}
4848

4949
impl JobTokenServer {
50-
pub(crate) fn new(client: Client) -> Result<Self, crate::Error> {
50+
pub(crate) fn new() -> Result<Self, crate::Error> {
51+
let client = jobserver();
5152
let (tx, rx) = mpsc::channel();
5253
// Push the implicit token. Since JobTokens only give back what they got,
5354
// there should be at most one global implicit token in the wild.
@@ -77,7 +78,7 @@ impl JobTokenServer {
7778

7879
/// Returns a suitable `jobserver::Client` used to coordinate
7980
/// parallelism between build scripts.
80-
pub(super) fn jobserver() -> jobserver::Client {
81+
fn jobserver() -> jobserver::Client {
8182
static INIT: Once = Once::new();
8283
static mut JOBSERVER: Option<jobserver::Client> = None;
8384

src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,8 +1306,7 @@ impl Build {
13061306
}
13071307

13081308
// Limit our parallelism globally with a jobserver.
1309-
let server = job_token::jobserver();
1310-
// Reacquire our process's token on drop
1309+
let mut tokens = crate::job_token::JobTokenServer::new()?;
13111310

13121311
// When compiling objects in parallel we do a few dirty tricks to speed
13131312
// things up:
@@ -1426,7 +1425,6 @@ impl Build {
14261425
};
14271426
}
14281427
})?;
1429-
let mut tokens = crate::job_token::JobTokenServer::new(server)?;
14301428
for obj in objs {
14311429
let (mut cmd, program) = self.create_compile_object_cmd(obj)?;
14321430
let token = tokens.acquire();

0 commit comments

Comments
 (0)