Skip to content

Commit

Permalink
Replace vendored OnceLock with dep once_cell
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Apr 18, 2024
1 parent 4e9adfe commit 2d3c859
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 134 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Expand Up @@ -26,9 +26,10 @@ jobserver = { version = "0.1.30", default-features = false, optional = true }
# Don't turn on the feature "std" for this, see https://github.com/rust-lang/cargo/issues/4866
# which is still an issue with `resolver = "1"`.
libc = { version = "0.2.62", default-features = false, optional = true }
once_cell = { version = "1.19", optional = true }

[features]
parallel = ["libc", "jobserver"]
parallel = ["libc", "jobserver", "once_cell"]

[dev-dependencies]
tempfile = "3"
Expand Down
12 changes: 7 additions & 5 deletions src/parallel/job_token.rs
@@ -1,6 +1,8 @@
use std::marker::PhantomData;

use crate::{parallel::once_lock::OnceLock, Error};
use crate::Error;

use once_cell::sync::OnceCell;

pub(crate) struct JobToken(PhantomData<()>);

Expand Down Expand Up @@ -34,7 +36,7 @@ impl JobTokenServer {
/// that has to be static so that it will be shared by all cc
/// compilation.
fn new() -> &'static Self {
static JOBSERVER: OnceLock<JobTokenServer> = OnceLock::new();
static JOBSERVER: OnceCell<JobTokenServer> = OnceCell::new();

JOBSERVER.get_or_init(|| {
unsafe { inherited_jobserver::JobServer::from_env() }
Expand Down Expand Up @@ -70,7 +72,7 @@ impl ActiveJobTokenServer {
}

mod inherited_jobserver {
use super::{JobToken, OnceLock};
use super::{JobToken, OnceCell};

use crate::{parallel::async_executor::YieldOnce, Error, ErrorKind};

Expand Down Expand Up @@ -136,7 +138,7 @@ mod inherited_jobserver {
pub(super) fn enter_active(&self) -> Result<ActiveJobServer<'_>, Error> {
Ok(ActiveJobServer {
jobserver: self,
helper_thread: OnceLock::new(),
helper_thread: OnceCell::new(),
})
}
}
Expand All @@ -162,7 +164,7 @@ mod inherited_jobserver {

pub(crate) struct ActiveJobServer<'a> {
jobserver: &'a JobServer,
helper_thread: OnceLock<HelperThread>,
helper_thread: OnceCell<HelperThread>,
}

impl<'a> ActiveJobServer<'a> {
Expand Down
1 change: 0 additions & 1 deletion src/parallel/mod.rs
@@ -1,4 +1,3 @@
pub(crate) mod async_executor;
pub(crate) mod job_token;
pub(crate) mod once_lock;
pub(crate) mod stderr;
127 changes: 0 additions & 127 deletions src/parallel/once_lock.rs

This file was deleted.

0 comments on commit 2d3c859

Please sign in to comment.