Skip to content

Commit 4ca7808

Browse files
committed
Further documentation refinements
1 parent 3637127 commit 4ca7808

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/job_token.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ impl Drop for JobToken {
1919

2020
impl JobToken {
2121
/// Ensure that this token is not put back into queue once it's dropped.
22-
/// This also leads to releasing it sooner for other processes to use, which is a good thing to do once you know that
23-
/// you're never going to request a token in this process again.
22+
/// This also leads to releasing it sooner for other processes to use,
23+
/// which is a correct thing to do once it is known that there won't be
24+
/// any more token acquisitions.
2425
pub(crate) fn forget(&mut self) {
2526
self.should_return_to_queue = false;
2627
}
2728
}
2829

2930
/// A thin wrapper around jobserver's Client.
30-
/// It would be perfectly fine to just use that, but we also want to reuse our own implicit token assigned for this build script.
31-
/// This struct manages that and gives out tokens without exposing whether they're implicit tokens or tokens from jobserver.
32-
/// Furthermore, instead of giving up job tokens, it keeps them around for reuse if we know we're going to request another token after freeing the current one.
31+
/// It would be perfectly fine to just use jobserver's Client, but we also want to reuse
32+
/// our own implicit token assigned for this build script. This struct manages that and
33+
/// gives out tokens without exposing whether they're implicit tokens or tokens from jobserver.
34+
/// Furthermore, instead of giving up job tokens, it keeps them around
35+
/// for reuse if we know we're going to request another token after freeing the current one.
3336
pub(crate) struct JobTokenServer {
3437
helper: HelperThread,
3538
tx: Sender<Option<Acquired>>,
@@ -51,7 +54,7 @@ impl JobTokenServer {
5154

5255
pub(crate) fn acquire(&mut self) -> JobToken {
5356
let token = if let Ok(token) = self.rx.try_recv() {
54-
// Opportunistically check if we already have a token for our own reuse.
57+
// Opportunistically check if there's a token that can be reused.
5558
token
5659
} else {
5760
// Cold path, request a token and block

src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,9 +1342,11 @@ impl Build {
13421342
loop {
13431343
let mut has_made_progress = false;
13441344
// If the other end of the pipe is already disconnected, then we're not gonna get any new jobs,
1345-
// so it doesn't make sense to reuse the tokens; in fact, releasing them as soon as possible (once we know that the other end is disconnected) is beneficial.
1346-
// Imagine that the last file built takes an hour to finish; in this scenario, by not releasing the tokens before other builds are done we'd effectively block other processes from
1347-
// starting sooner - even though we only need one token, not however many we've acquired.
1345+
// so it doesn't make sense to reuse the tokens; in fact,
1346+
// releasing them as soon as possible (once we know that the other end is disconnected) is beneficial.
1347+
// Imagine that the last file built takes an hour to finish; in this scenario,
1348+
// by not releasing the tokens before that last file is done we would effectively block other processes from
1349+
// starting sooner - even though we only need one token for that last file, not N others that were acquired.
13481350
let mut is_disconnected = false;
13491351
// Reading new pending tasks
13501352
loop {

0 commit comments

Comments
 (0)