Replace crossbeam with std's scoped threads

This commit is contained in:
Lukas Wirth 2022-08-11 17:12:25 +02:00
parent dea163970a
commit f9d1b26a96
3 changed files with 6 additions and 37 deletions

View file

@ -26,6 +26,7 @@ use std::{
ffi::OsString,
fs,
path::{Path, PathBuf},
thread,
time::SystemTime,
};
@ -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)),
};
@ -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();