Amanieu / thread_local-rs

Per-object thread-local storage for Rust
Apache License 2.0
328 stars 41 forks source link

Remove once_cell dependency #76

Closed james7132 closed 5 months ago

james7132 commented 5 months ago

Fixes #50. Avoids the OnceCell by making ThreadIdManager const-initializable. This doesn't require a MSRV bump as aggressive as #64, as it only requires 1.63 to make Mutex::new const. Unfortunately BinaryHeap::new is still not const, so this PR wraps the freelist in an Option to allow initializing it to zero. It should still be cheaper than the atomic check of a Lazy, and this is only done when new threads are registered.