fn main() {
assert_eq!(
num_threads::num_threads(),
std::num::NonZeroUsize::new(1)
)
}
cargo run --target aarch64-apple-darwin
Compiling test-threadcount v1.0.0 (...)
Finished dev [unoptimized + debuginfo] target(s) in 0.51s
Running `target/aarch64-apple-darwin/debug/test-threadcount`
cargo run --target x86_64-apple-darwin
Compiling test-threadcount v1.0.0 (...)
Finished dev [unoptimized + debuginfo] target(s) in 0.19s
Running `target/x86_64-apple-darwin/debug/test-threadcount`
thread 'main' panicked at src/main.rs:2:5:
assertion `left == right` failed
left: Some(2)
right: Some(1)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
LLDB says it's 1 in both cases, which appears correct to me:
lldb target/x86_64-apple-darwin/debug/test-threadcount
(lldb) target create "target/x86_64-apple-darwin/debug/test-threadcount"
Current executable set to '.../target/x86_64-apple-darwin/debug/test-threadcount' (x86_64).
(lldb) break set --file src/main.rs --line 3
Breakpoint 1: where = test-threadcount`test_threadcount::main::h0b4a5b9d24100f68 + 11 at main.rs:3:9, address = 0x00000001000019ab
(lldb) run
Process 48950 launched: '.../target/x86_64-apple-darwin/debug/test-threadcount' (x86_64)
warning: libobjc.A.dylib is being read from process memory. This indicates that LLDB could not read from the host's in-memory shared cache. This will likely reduce debugging performance.
Process 48950 stopped
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x00000001000019ab test-threadcount`test_threadcount::main::h0b4a5b9d24100f68 at main.rs:3:9
1 fn main() {
2 assert_eq!(
-> 3 num_threads::num_threads(),
4 std::num::NonZeroUsize::new(1)
5 )
6 }
Target 0: (test-threadcount) stopped.
(lldb) thread list
Process 48950 stopped
* thread #1: tid = 0x2dfb06, 0x00000001000019ab test-threadcount`test_threadcount::main::h0b4a5b9d24100f68 at main.rs:3:9, name = 'main', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
(lldb) ^D
Project info
rustc --version
rustc 1.75.0 (82e1608df 2023-12-21)
cargo --version
cargo 1.75.0 (1d8b05cdd 2023-11-20)
Cargo.toml
[package]
name = "test-threadcount"
version = "1.0.0"
[dependencies]
num_threads = "0.1.6"
Cargo.lock
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "libc"
version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "num_threads"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
dependencies = [
"libc",
]
[[package]]
name = "test-threadcount"
version = "1.0.0"
dependencies = [
"num_threads",
]
LLDB says it's 1 in both cases, which appears correct to me:
Project info
Cargo.tomlCargo.lock