Skip to content

Commit 54c95ea

Browse files
author
wangxu
committed
don't use affinity on macos
1 parent ce5489b commit 54c95ea

File tree

4 files changed

+352
-353
lines changed

4 files changed

+352
-353
lines changed

thread/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ thread-priority = "0.9.2"
1111
thread-amount = "0.1.3"
1212
crossbeam = "0.8.2"
1313
thread-control = "0.1.2"
14-
affinity = "0.1.2"
1514
rayon = "1.5.3"
1615
go-spawn = "0.1.2"
1716
num_threads = "0.1.6"
1817
parking = "2.0.0"
18+
19+
[target.'cfg(any(windows, linux))'.dependencies]
20+
affinity = "0.1.2"

thread/src/lib.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
pub mod threads;
2-
3-
pub use threads::*;
4-
5-
6-
pub fn panic_example() {
7-
println!("Hello, world!");
8-
9-
let h = std::thread::spawn(|| {
10-
std::thread::sleep(std::time::Duration::from_millis(1000));
11-
panic!("boom");
12-
});
13-
14-
let r = h.join();
15-
match r {
16-
Ok(r) => println!("All is well! {:?}", r),
17-
Err(e) => println!("Got an error! {:?}", e)
18-
}
19-
20-
println!("Exiting main!")
21-
}
1+
pub mod threads;
2+
3+
pub use threads::*;
4+
5+
pub fn panic_example() {
6+
println!("Hello, world!");
7+
8+
let h = std::thread::spawn(|| {
9+
std::thread::sleep(std::time::Duration::from_millis(1000));
10+
panic!("boom");
11+
});
12+
13+
let r = h.join();
14+
match r {
15+
Ok(r) => println!("All is well! {:?}", r),
16+
Err(e) => println!("Got an error! {:?}", e),
17+
}
18+
19+
println!("Exiting main!")
20+
}

thread/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ fn main() {
2323

2424
control_thread();
2525

26+
#[cfg(not(target_os = "macos"))]
2627
use_affinity();
2728

2829
go_thread();
@@ -31,4 +32,3 @@ fn main() {
3132

3233
panic_example();
3334
}
34-

0 commit comments

Comments
 (0)