Skip to content

Commit 2c9854c

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 24cf5a3 commit 2c9854c

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/librustc_codegen_ssa/back/write.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -978,10 +978,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
978978
// get tokens on `coordinator_receive` which will
979979
// get managed in the main loop below.
980980
let coordinator_send2 = coordinator_send.clone();
981-
let helper = rustc_jobserver::client().into_helper_thread(move |token| {
982-
let token = token.expect("acquired token successfully");
981+
let helper = rustc_jobserver::helper_thread(move |token| {
983982
drop(coordinator_send2.send(Box::new(Message::Token::<B>(token))));
984-
}).expect("failed to spawn helper thread");
983+
});
985984

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

src/librustc_jobserver/lib.rs

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

45
lazy_static! {
@@ -33,8 +34,12 @@ 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 F: FnMut(Acquired) + Send + 'static,
39+
{
40+
GLOBAL_CLIENT.clone().into_helper_thread(move |token| {
41+
cb(token.expect("acquire token"))
42+
}).expect("failed to spawn helper thread")
3843
}
3944

4045
pub fn acquire_thread() {

0 commit comments

Comments
 (0)