Skip to content

Commit ac96772

Browse files
Hide the jobserver Client from the public view
Future commits will be changing the jobserver integration to have custom logic to enable it to appropriately talk to Cargo, so we can't have other code that directly talks to the jobserver.
1 parent 2adb418 commit ac96772

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/librustc_codegen_ssa/back/write.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -994,12 +994,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
994994
// get tokens on `coordinator_receive` which will
995995
// get managed in the main loop below.
996996
let coordinator_send2 = coordinator_send.clone();
997-
let helper = rustc_jobserver::client()
998-
.into_helper_thread(move |token| {
999-
let token = token.expect("acquired token successfully");
1000-
drop(coordinator_send2.send(Box::new(Message::Token::<B>(token))));
1001-
})
1002-
.expect("failed to spawn helper thread");
997+
let helper = rustc_jobserver::helper_thread(move |token| {
998+
drop(coordinator_send2.send(Box::new(Message::Token::<B>(token))));
999+
});
10031000

10041001
let mut each_linked_rlib_for_lto = Vec::new();
10051002
drop(link::each_linked_rlib(crate_info, &mut |cnum, path| {

src/librustc_jobserver/lib.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
pub use jobserver::{Acquired, Client};
1+
pub use jobserver::Acquired;
2+
use jobserver::{Client, HelperThread};
23
use lazy_static::lazy_static;
34

45
lazy_static! {
@@ -33,8 +34,14 @@ pub fn initialize() {
3334
lazy_static::initialize(&GLOBAL_CLIENT)
3435
}
3536

36-
pub fn client() -> Client {
37-
GLOBAL_CLIENT.clone()
37+
pub fn helper_thread<F>(mut cb: F) -> HelperThread
38+
where
39+
F: FnMut(Acquired) + Send + 'static,
40+
{
41+
GLOBAL_CLIENT
42+
.clone()
43+
.into_helper_thread(move |token| cb(token.expect("acquire token")))
44+
.expect("failed to spawn helper thread")
3845
}
3946

4047
pub fn acquire_thread() {

0 commit comments

Comments
 (0)