mirror of
https://github.com/rust-lang/cargo
synced 2024-08-28 11:50:23 +00:00
Use std:🧵:scope to replace crossbeam
This commit is contained in:
parent
1ac43cf649
commit
33497512a8
|
@ -21,7 +21,6 @@ bytesize = "1.0"
|
||||||
cargo-platform = { path = "crates/cargo-platform", version = "0.1.2" }
|
cargo-platform = { path = "crates/cargo-platform", version = "0.1.2" }
|
||||||
cargo-util = { path = "crates/cargo-util", version = "0.2.1" }
|
cargo-util = { path = "crates/cargo-util", version = "0.2.1" }
|
||||||
crates-io = { path = "crates/crates-io", version = "0.34.0" }
|
crates-io = { path = "crates/crates-io", version = "0.34.0" }
|
||||||
crossbeam-utils = "0.8"
|
|
||||||
curl = { version = "0.4.43", features = ["http2"] }
|
curl = { version = "0.4.43", features = ["http2"] }
|
||||||
curl-sys = "0.4.55"
|
curl-sys = "0.4.55"
|
||||||
env_logger = "0.9.0"
|
env_logger = "0.9.0"
|
||||||
|
|
|
@ -55,11 +55,11 @@ use std::fmt::Write as _;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::marker;
|
use std::marker;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::thread::{self, Scope};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::{format_err, Context as _};
|
use anyhow::{format_err, Context as _};
|
||||||
use cargo_util::ProcessBuilder;
|
use cargo_util::ProcessBuilder;
|
||||||
use crossbeam_utils::thread::Scope;
|
|
||||||
use jobserver::{Acquired, Client, HelperThread};
|
use jobserver::{Acquired, Client, HelperThread};
|
||||||
use log::{debug, trace};
|
use log::{debug, trace};
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
|
@ -556,22 +556,21 @@ impl<'cfg> JobQueue<'cfg> {
|
||||||
.take()
|
.take()
|
||||||
.map(move |srv| srv.start(move |msg| messages.push(Message::FixDiagnostic(msg))));
|
.map(move |srv| srv.start(move |msg| messages.push(Message::FixDiagnostic(msg))));
|
||||||
|
|
||||||
crossbeam_utils::thread::scope(move |scope| {
|
thread::scope(
|
||||||
match state.drain_the_queue(cx, plan, scope, &helper) {
|
move |scope| match state.drain_the_queue(cx, plan, scope, &helper) {
|
||||||
Some(err) => Err(err),
|
Some(err) => Err(err),
|
||||||
None => Ok(()),
|
None => Ok(()),
|
||||||
}
|
},
|
||||||
})
|
)
|
||||||
.expect("child threads shouldn't panic")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'cfg> DrainState<'cfg> {
|
impl<'cfg> DrainState<'cfg> {
|
||||||
fn spawn_work_if_possible(
|
fn spawn_work_if_possible<'s>(
|
||||||
&mut self,
|
&mut self,
|
||||||
cx: &mut Context<'_, '_>,
|
cx: &mut Context<'_, '_>,
|
||||||
jobserver_helper: &HelperThread,
|
jobserver_helper: &HelperThread,
|
||||||
scope: &Scope<'_>,
|
scope: &'s Scope<'s, '_>,
|
||||||
) -> CargoResult<()> {
|
) -> CargoResult<()> {
|
||||||
// Dequeue as much work as we can, learning about everything
|
// Dequeue as much work as we can, learning about everything
|
||||||
// possible that can run. Note that this is also the point where we
|
// possible that can run. Note that this is also the point where we
|
||||||
|
@ -807,11 +806,11 @@ impl<'cfg> DrainState<'cfg> {
|
||||||
///
|
///
|
||||||
/// This returns an Option to prevent the use of `?` on `Result` types
|
/// This returns an Option to prevent the use of `?` on `Result` types
|
||||||
/// because it is important for the loop to carefully handle errors.
|
/// because it is important for the loop to carefully handle errors.
|
||||||
fn drain_the_queue(
|
fn drain_the_queue<'s>(
|
||||||
mut self,
|
mut self,
|
||||||
cx: &mut Context<'_, '_>,
|
cx: &mut Context<'_, '_>,
|
||||||
plan: &mut BuildPlan,
|
plan: &mut BuildPlan,
|
||||||
scope: &Scope<'_>,
|
scope: &'s Scope<'s, '_>,
|
||||||
jobserver_helper: &HelperThread,
|
jobserver_helper: &HelperThread,
|
||||||
) -> Option<anyhow::Error> {
|
) -> Option<anyhow::Error> {
|
||||||
trace!("queue: {:#?}", self.queue);
|
trace!("queue: {:#?}", self.queue);
|
||||||
|
@ -997,7 +996,7 @@ impl<'cfg> DrainState<'cfg> {
|
||||||
///
|
///
|
||||||
/// Fresh jobs block until finished (which should be very fast!), Dirty
|
/// Fresh jobs block until finished (which should be very fast!), Dirty
|
||||||
/// jobs will spawn a thread in the background and return immediately.
|
/// jobs will spawn a thread in the background and return immediately.
|
||||||
fn run(&mut self, unit: &Unit, job: Job, cx: &Context<'_, '_>, scope: &Scope<'_>) {
|
fn run<'s>(&mut self, unit: &Unit, job: Job, cx: &Context<'_, '_>, scope: &'s Scope<'s, '_>) {
|
||||||
let id = JobId(self.next_id);
|
let id = JobId(self.next_id);
|
||||||
self.next_id = self.next_id.checked_add(1).unwrap();
|
self.next_id = self.next_id.checked_add(1).unwrap();
|
||||||
|
|
||||||
|
@ -1072,7 +1071,7 @@ impl<'cfg> DrainState<'cfg> {
|
||||||
}
|
}
|
||||||
Freshness::Dirty => {
|
Freshness::Dirty => {
|
||||||
self.timings.add_dirty();
|
self.timings.add_dirty();
|
||||||
scope.spawn(move |_| {
|
scope.spawn(move || {
|
||||||
doit(JobState {
|
doit(JobState {
|
||||||
id,
|
id,
|
||||||
messages: messages.clone(),
|
messages: messages.clone(),
|
||||||
|
|
Loading…
Reference in a new issue