From ca4dd26ec0b5d69417ee0cea5168fc6db33a7035 Mon Sep 17 00:00:00 2001 From: James Liu Date: Thu, 21 Mar 2024 22:16:58 -0700 Subject: [PATCH] Fix: Implement Send/Sync for FixedBitset (#124) --- Cargo.toml | 2 +- README.md | 6 +++++- src/lib.rs | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 72d93ca..865065e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fixedbitset" -version = "0.5.5" +version = "0.5.6" authors = ["bluss"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/README.md b/README.md index d71e2e8..09d8380 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,16 @@ Please read the [API documentation here](https://docs.rs/fixedbitset/) # Recent Changes -- 0.5.5 +- 0.5.6 + - Fixed FixedBitset not implementing Send/Sync due to the stack size shrink. +- 0.5.5 (yanked) - [#116](https://github.com/petgraph/fixedbitset/pull/116): Add functions for counting the results of a set operation (`union_count`, `intersection_count`, `difference_count`, `symmetric_difference_count`) by @james7132. - [#118](https://github.com/petgraph/fixedbitset/pull/118): Shrink the stack size of FixedBitset. There should be zero stack size overhead compared to a Vec. - [#119](https://github.com/petgraph/fixedbitset/pull/119): Fix builds for wasm32. + - [#120](https://github.com/petgraph/fixedbitset/pull/119): Add more utility functions that were previously missing from the public interface: + `contains_any_in_range`, `contains_all_in_range`, `minimum`, `maximum`, `is_full`, `count_zeroes`, and `remove_range`. - [#121](https://github.com/petgraph/fixedbitset/pull/121): Add support for SIMD acceleration for AVX builds. - 0.5.4 - [#112](https://github.com/petgraph/fixedbitset/pull/112): Fix undefined behavior in IntoOnes and setup testing with MIRI by @SkiFire13 diff --git a/src/lib.rs b/src/lib.rs index 4616461..10a871c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,6 +76,12 @@ pub struct FixedBitSet { pub(crate) length: usize, } +// SAFETY: FixedBitset contains no thread-local state and can be safely sent between threads +unsafe impl Send for FixedBitSet {} +// SAFETY: FixedBitset does not provide simultaneous unsynchronized mutable access to the +// underlying buffer. +unsafe impl Sync for FixedBitSet {} + impl FixedBitSet { /// Create a new empty **FixedBitSet**. pub const fn new() -> Self {