Skip to content

Commit

Permalink
Refactor: ActiveJobTokenServer::new no longer returns Result
Browse files Browse the repository at this point in the history
There is no need to, it never fails.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Apr 18, 2024
1 parent 3361c4d commit 2847b2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -1449,7 +1449,7 @@ impl Build {
}

// Limit our parallelism globally with a jobserver.
let tokens = parallel::job_token::ActiveJobTokenServer::new()?;
let tokens = parallel::job_token::ActiveJobTokenServer::new();

// When compiling objects in parallel we do a few dirty tricks to speed
// things up:
Expand Down
14 changes: 6 additions & 8 deletions src/parallel/job_token.rs
Expand Up @@ -52,14 +52,12 @@ pub(crate) enum ActiveJobTokenServer {
}

impl ActiveJobTokenServer {
pub(crate) fn new() -> Result<Self, Error> {
pub(crate) fn new() -> Self {
match JobTokenServer::new() {
JobTokenServer::Inherited(inherited_jobserver) => {
inherited_jobserver.enter_active().map(Self::Inherited)
}
JobTokenServer::InProcess(inprocess_jobserver) => {
Ok(Self::InProcess(inprocess_jobserver))
Self::Inherited(inherited_jobserver.enter_active())
}
JobTokenServer::InProcess(inprocess_jobserver) => Self::InProcess(inprocess_jobserver),
}
}

Expand Down Expand Up @@ -135,11 +133,11 @@ mod inherited_jobserver {
}
}

pub(super) fn enter_active(&self) -> Result<ActiveJobServer<'_>, Error> {
Ok(ActiveJobServer {
pub(super) fn enter_active(&self) -> ActiveJobServer<'_> {
ActiveJobServer {
jobserver: self,
helper_thread: OnceCell::new(),
})
}
}
}

Expand Down

0 comments on commit 2847b2c

Please sign in to comment.