Move `src/*.rs` to `src/bin/*.rs` which are automatically inferred as binaries and move `src/utils.rs` to `src/lib.rs` which is compiled as a reusable library for each of the binaries we're building.
26 lines
915 B
Rust
26 lines
915 B
Rust
pub fn init_file_per_thread_logger(prefix: &'static str) {
|
|
file_per_thread_logger::initialize(prefix);
|
|
|
|
// Extending behavior of default spawner:
|
|
// https://docs.rs/rayon/1.1.0/rayon/struct.ThreadPoolBuilder.html#method.spawn_handler
|
|
// Source code says DefaultSpawner is implementation detail and
|
|
// shouldn't be used directly.
|
|
rayon::ThreadPoolBuilder::new()
|
|
.spawn_handler(move |thread| {
|
|
let mut b = std::thread::Builder::new();
|
|
if let Some(name) = thread.name() {
|
|
b = b.name(name.to_owned());
|
|
}
|
|
if let Some(stack_size) = thread.stack_size() {
|
|
b = b.stack_size(stack_size);
|
|
}
|
|
b.spawn(move || {
|
|
file_per_thread_logger::initialize(prefix);
|
|
thread.run()
|
|
})?;
|
|
Ok(())
|
|
})
|
|
.build_global()
|
|
.unwrap();
|
|
}
|