Skip to content

Commit

Permalink
Auto merge of #13001 - Veykril:scoped, r=Veykril
Browse files Browse the repository at this point in the history
Replace crossbeam with std's scoped threads

Probably best to wait a week or two so we don't immediately give linux packagers problems again
  • Loading branch information
bors committed Aug 22, 2022
2 parents dea1639 + f9d1b26 commit c2310a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 37 deletions.
25 changes: 0 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/proc-macro-srv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ tt = { path = "../tt", version = "0.0.0" }
mbe = { path = "../mbe", version = "0.0.0" }
paths = { path = "../paths", version = "0.0.0" }
proc-macro-api = { path = "../proc-macro-api", version = "0.0.0" }
crossbeam = "0.8.1"

[dev-dependencies]
expect-test = "1.4.0"
Expand Down
17 changes: 6 additions & 11 deletions crates/proc-macro-srv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use std::{
ffi::OsString,
fs,
path::{Path, PathBuf},
thread,
time::SystemTime,
};

Expand Down Expand Up @@ -65,18 +66,16 @@ impl ProcMacroSrv {

let macro_body = task.macro_body.to_subtree();
let attributes = task.attributes.map(|it| it.to_subtree());
// FIXME: replace this with std's scoped threads once they stabilize
// (then remove dependency on crossbeam)
let result = crossbeam::scope(|s| {
let res = match s
.builder()
let result = thread::scope(|s| {
let thread = thread::Builder::new()
.stack_size(EXPANDER_STACK_SIZE)
.name(task.macro_name.clone())
.spawn(|_| {
.spawn_scoped(s, || {
expander
.expand(&task.macro_name, &macro_body, attributes.as_ref())
.map(|it| FlatTree::new(&it))
}) {
});
let res = match thread {
Ok(handle) => handle.join(),
Err(e) => std::panic::resume_unwind(Box::new(e)),
};
Expand All @@ -86,10 +85,6 @@ impl ProcMacroSrv {
Err(e) => std::panic::resume_unwind(e),
}
});
let result = match result {
Ok(result) => result,
Err(e) => std::panic::resume_unwind(e),
};

prev_env.rollback();

Expand Down

0 comments on commit c2310a0

Please sign in to comment.