commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
55413956c36aeab47feb8c04d1b7a044d6df336a | Roland Kuhn | 2024-11-20T16:29:34 | release v1.0.2 | diff --git a/Cargo.toml b/Cargo.toml
index 2b1d258..59e8d21 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sync_wrapper"
-version = "1.0.1"
+version = "1.0.2"
authors = ["Actyx AG <developer@actyx.io>"]
edition = "2021"
description = "A tool for enlisting the compiler's help in proving ... | 1 | 1 | 1 |
3b20009c1590a81754d81ad201c84a7fe1445970 | Anthony Ramine | 2024-11-20T09:39:02 | Implement Debug for SyncFuture and SyncStream | diff --git a/src/lib.rs b/src/lib.rs
index 2800d9a..a508e2f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -212,6 +212,11 @@ impl <F: Future> Future for SyncFuture<F> {
inner.poll(cx)
}
}
+impl<T> Debug for SyncFuture<T> {
+ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
+ f.pad("SyncFuture... | 1 | 11 | 1 |
3de3ec10cc2bfaa7b44922b85bb07d908dd08c9a | Roland Kuhn | 2024-04-08T08:41:41 | switch to edition 2021 and all-features | diff --git a/Cargo.toml b/Cargo.toml
index c0209a1..2b1d258 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
name = "sync_wrapper"
version = "1.0.1"
authors = ["Actyx AG <developer@actyx.io>"]
-edition = "2018"
+edition = "2021"
description = "A tool for enlisting the compiler's help in proving the absence ... | 1 | 2 | 2 |
ec3abb02497d85698d805ea8bcb5d2ef97b81303 | Roland Kuhn | 2024-04-08T08:31:57 | release 1.0.1 | diff --git a/Cargo.toml b/Cargo.toml
index e7a9049..c0209a1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sync_wrapper"
-version = "1.0.0"
+version = "1.0.1"
authors = ["Actyx AG <developer@actyx.io>"]
edition = "2018"
description = "A tool for enlisting the compiler's help in proving ... | 1 | 1 | 1 |
1a4bdf6f056387c9aacd536b9ed5d581c2830b18 | Paolo Barbolini | 2024-04-08T08:21:21 | Enable `futures` feature in docs.rs build | diff --git a/Cargo.toml b/Cargo.toml
index 10e3e24..e7a9049 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,3 +21,7 @@ futures = { version = "0.3" }
[dependencies]
futures-core = { version = "0.3", default-features = false, optional = true }
+
+[package.metadata.docs.rs]
+features = ["futures"]
+ | 1 | 4 | 0 |
763f49a9b53dcd263f00525cca5d11b6fef101f0 | Roland Kuhn | 2024-03-14T21:38:26 | release 1.0.0 | diff --git a/Cargo.toml b/Cargo.toml
index 678b869..10e3e24 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sync_wrapper"
-version = "0.1.2"
+version = "1.0.0"
authors = ["Actyx AG <developer@actyx.io>"]
edition = "2018"
description = "A tool for enlisting the compiler's help in proving ... | 1 | 1 | 1 |
659ef11fe202fd344efc7c1cc25007cbface5d3a | Ali Sajid Imami | 2024-03-12T16:26:01 | style: replace the smartquote in Cargo.toml with a standard apostrophe | diff --git a/Cargo.toml b/Cargo.toml
index 22aa494..678b869 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@ name = "sync_wrapper"
version = "0.1.2"
authors = ["Actyx AG <developer@actyx.io>"]
edition = "2018"
-description = "A tool for enlisting the compiler’s help in proving the absence of concurrency"
+de... | 1 | 1 | 1 |
7ebf2994396d88738067a09cf354cbb0d6ac1084 | Roland Kuhn | 2023-02-01T15:50:03 | make futures-core dep optional and release 0.1.2 | diff --git a/Cargo.toml b/Cargo.toml
index 6fffa06..22aa494 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "sync_wrapper"
-version = "0.1.1"
+version = "0.1.2"
authors = ["Actyx AG <developer@actyx.io>"]
edition = "2018"
description = "A tool for enlisting the compiler’s help in proving ... | 2 | 10 | 3 |
778cffe43eff21bed80193e122178daed90e7ad0 | Akira Hayakawa | 2021-08-16T08:43:07 | add default wrapper implementations (#1) | diff --git a/Cargo.toml b/Cargo.toml
index 93e28e7..6fffa06 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,3 +14,7 @@ categories = ["concurrency"]
[dev-dependencies]
pin-project-lite = "0.2.7"
+futures = { version = "0.3" }
+
+[dependencies]
+futures-core = { version = "0.3", default-features = false }
\ No newlin... | 2 | 65 | 0 |
0cad592ae373b112f7691f1a730f4ac9c3a24a1a | KaiJewson | 2021-08-14T06:28:47 | Link to repository in Cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index 4e2d988..280fc67 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,6 +5,7 @@ authors = ["Actyx AG <developer@actyx.io>"]
edition = "2018"
description = "A tool for enlisting the compiler’s help in proving the absence of concurrency"
readme = "README.md"
+repository = "https://... | 1 | 1 | 0 |
1b7f37f70f90d89970ea820de45b77bcb7abc17f | KaiJewson | 2021-08-14T06:26:07 | Make library no_std | diff --git a/src/lib.rs b/src/lib.rs
index 31c2eef..50ee779 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -18,6 +18,7 @@
//! This library is inspired by [this discussion](https://internals.rust-lang.org/t/what-shall-sync-mean-across-an-await/12020/2).
#![doc(html_logo_url = "https://developer.actyx.com/img/logo.svg")]
... | 1 | 1 | 0 |
3052a6be42a428e5d0c3dde7ae94ce4968930a07 | KaiJewson | 2021-08-14T06:38:51 | Implement `From<T>` for `SyncWrapper<T>` | diff --git a/src/lib.rs b/src/lib.rs
index 3b9a43a..33f75ab 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -138,3 +138,9 @@ impl<T: Default> Default for SyncWrapper<T> {
Self::new(T::default())
}
}
+
+impl<T> From<T> for SyncWrapper<T> {
+ fn from(value: T) -> Self {
+ Self::new(value)
+ }
+} | 1 | 6 | 0 |
c6e71fe1cc075a2d90bb556e26983addf8669a08 | KaiJewson | 2021-08-14T06:22:26 | Make `SyncWrapper::new` const | diff --git a/src/lib.rs b/src/lib.rs
index 053f1c1..31c2eef 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -70,7 +70,7 @@ impl<T> SyncWrapper<T> {
///
/// let mutex = SyncWrapper::new(42);
/// ```
- pub fn new(value: T) -> Self {
+ pub const fn new(value: T) -> Self {
Self(value)
} | 1 | 1 | 1 |
38dc8f38ada467e689b3b68bc2d508ea0d82690a | KaiJewson | 2021-08-14T06:38:08 | Implement `Default` for `SyncWrapper` | diff --git a/src/lib.rs b/src/lib.rs
index 4387dd5..3b9a43a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -132,3 +132,9 @@ impl<T> Debug for SyncWrapper<T> {
f.pad("SyncWrapper")
}
}
+
+impl<T: Default> Default for SyncWrapper<T> {
+ fn default() -> Self {
+ Self::new(T::default())
+ }
+} | 1 | 6 | 0 |
54367f1ae81895947afa0334ee7d7bc6cfd24e92 | KaiJewson | 2021-08-14T06:35:01 | Implement `Debug` for `SyncWrapper`
This change allows users to `#[derive(Debug)]` on types that contain
`SyncWrapper`. The actual implementation does not give any useful
information, but that is fine because nothing could be done anyway. | diff --git a/src/lib.rs b/src/lib.rs
index 053f1c1..4387dd5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -19,6 +19,8 @@
#![doc(html_logo_url = "https://developer.actyx.com/img/logo.svg")]
#![doc(html_favicon_url = "https://developer.actyx.com/img/favicon.ico")]
+use core::fmt::{self, Debug, Formatter};
+
/// A mutu... | 1 | 8 | 0 |
02b6469b0b55bfde5083d40e5762b5d281d67837 | KaiJewson | 2021-08-14T06:21:37 | Add `SyncWrapper::get_pin_mut` | diff --git a/Cargo.lock b/Cargo.lock
index bb937a9..08566d7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,5 +1,16 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.7"
+source = "registry+https://github.... | 3 | 49 | 0 |
b911fe598b92184a9b99cb1c617e074d1b215979 | Daniel Henry-Mantilla | 2021-05-17T16:15:22 | Remove the `T : Send` for `SyncWrapper` to be `Sync`
Indeed, it is not necessary: `Inner : Send => Wrapper : Sync` is only required for `Wrapper`s allowing `&Wrapper -> &mut Inner` code paths such as `Mutex` or, less obviously, `Arc` | diff --git a/src/lib.rs b/src/lib.rs
index b10e8e1..053f1c1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -123,4 +123,4 @@ impl<T> SyncWrapper<T> {
// this is safe because the only operations permitted on this data structure require exclusive
// access or ownership
-unsafe impl<T: Send> Sync for SyncWrapper<T> {}
+un... | 1 | 1 | 1 |
79371d8ece07f5916da9ec014208f8ae29593568 | Alexander Kjäll | 2025-09-14T18:09:10 | fix x86 32 bit build | diff --git a/src/lib.rs b/src/lib.rs
index 53856cd..aede1a5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -535,6 +535,13 @@ mod tests {
assert_serde(&a, 30);
}
+ // on 32-bit x86 64 bit atomics exist, but they can't be used to implement
+ // atomic<i64> because AtomicI64 has a greater alignment requ... | 1 | 18 | 0 |
cecd5f95c38a509e8231c1479f625e4abab7612a | Ben Pfaff | 2025-06-03T17:34:14 | Use `Relaxed` memory ordering for `Debug` and serde serialization.
Signed-off-by: Ben Pfaff <blp@cs.stanford.edu> | diff --git a/src/lib.rs b/src/lib.rs
index 1de280f..53856cd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -91,7 +91,7 @@ impl<T: Default> Default for Atomic<T> {
impl<T: NoUninit + fmt::Debug> fmt::Debug for Atomic<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("Atomic")
- ... | 2 | 2 | 2 |
802ec51f2b4773d9a59b96a4cb9605838980d152 | Amanieu d'Antras | 2023-05-15T15:17:50 | Bump version to 0.5.3 | diff --git a/Cargo.toml b/Cargo.toml
index a521f9f..6471054 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.5.2"
+version = "0.5.3"
edition = "2018"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
@@ -14,4 +14,4 @@ k... | 1 | 2 | 2 |
5989a43e97cf96a99c95ca1c83a5fdf3af752b24 | Albin Hedman | 2023-01-12T11:23:36 | Fix wrong cfg_attr syntax
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com> | diff --git a/src/lib.rs b/src/lib.rs
index e0065b1..1f89ca6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -33,7 +33,7 @@
#![warn(missing_docs)]
#![warn(rust_2018_idioms)]
#![no_std]
-#![cfg_attr(nightly, feature(integer_atomics))]
+#![cfg_attr(feature = "nightly", feature(integer_atomics))]
#[cfg(any(test, feature ... | 1 | 1 | 1 |
c1fc7b2b405d8c0c85525b9e0e92a93563629605 | Albin Hedman | 2023-01-12T09:45:01 | Put i/u128 behind feature | diff --git a/Cargo.toml b/Cargo.toml
index 0fd9c94..a521f9f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,3 +14,4 @@ keywords = ["atomic", "no_std"]
default = ["fallback"]
std = []
fallback = []
+nightly = []
\ No newline at end of file
diff --git a/src/lib.rs b/src/lib.rs
index 10f6c6d..e0065b1 100644
--- a/src/l... | 3 | 10 | 5 |
f3b26c9004fc2297e492b43930a230915c39aa8a | Albin Hedman | 2023-01-12T09:04:19 | Use target_has_atomic instead of depending on autocfg | diff --git a/Cargo.toml b/Cargo.toml
index d8474c5..0fd9c94 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,6 +14,3 @@ keywords = ["atomic", "no_std"]
default = ["fallback"]
std = []
fallback = []
-
-[build-dependencies]
-autocfg = "1"
diff --git a/build.rs b/build.rs
deleted file mode 100644
index 4cf4274..0000000
... | 4 | 51 | 46 |
319aa964317bd12c7fd245338b97cee747b3efa3 | Amanieu d'Antras | 2022-05-24T12:56:28 | Bump version to 0.5.2 | diff --git a/Cargo.toml b/Cargo.toml
index 80b613b..d8474c5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.5.1"
+version = "0.5.2"
edition = "2018"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type" | 1 | 1 | 1 |
fdf55c42a5778728e024c65578a0edb0e6b27082 | Amanieu d'Antras | 2022-05-23T22:14:08 | Work around rust-lang/rust#87341
UnsafeCell unfortunately lets the niches of the inner type "leak
through" to the outer type, which can cause unsoundness.
Fixes #29 | diff --git a/src/fallback.rs b/src/fallback.rs
index 8b7e861..2f9f7fd 100644
--- a/src/fallback.rs
+++ b/src/fallback.rs
@@ -6,12 +6,13 @@
// copied, modified, or distributed except according to those terms.
use core::cmp;
+use core::hint;
use core::mem;
use core::num::Wrapping;
use core::ops;
use core::ptr;
u... | 2 | 33 | 23 |
4902333f255c3b0292da40f8a9ea6cb17e8fcd14 | Amanieu d'Antras | 2021-11-10T18:59:24 | Bump version to v0.5.1 | diff --git a/Cargo.toml b/Cargo.toml
index df5c1d4..80b613b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.5.0"
+version = "0.5.1"
edition = "2018"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type" | 1 | 1 | 1 |
da129b4fba7f823cc268c87962e9a05694d3d913 | Amanieu d'Antras | 2021-11-10T18:58:26 | Fix documentation for allowed failure orderings on compare_exchange
Fixes #24 | diff --git a/src/lib.rs b/src/lib.rs
index a159daf..09ad879 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -171,7 +171,7 @@ impl<T: Copy> Atomic<T> {
/// `compare_exchange` takes two `Ordering` arguments to describe the memory
/// ordering of this operation. The first describes the required ordering if
/// ... | 1 | 2 | 2 |
0932d0fd57e3ea0f0d7d18389129dbad77407816 | Adam Reichold | 2020-08-02T06:25:29 | Make fallback implementation optional to increase confidence in performance characteristics. | diff --git a/Cargo.toml b/Cargo.toml
index ce11171..f4b8d30 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,9 @@ readme = "README.md"
keywords = ["atomic", "no_std"]
[features]
+default = ["fallback"]
std = []
+fallback = []
[build-dependencies]
autocfg = "1"
diff --git a/src/lib.rs b/src/lib.rs
index 71... | 3 | 10 | 0 |
35579fc88bfc34438054b646ee81695ccc61dc69 | Adam Reichold | 2020-08-04T18:19:15 | Upgrade to Rust edition 2018. | diff --git a/Cargo.toml b/Cargo.toml
index d8bae78..ce11171 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,7 @@
[package]
name = "atomic"
version = "0.4.6"
+edition = "2018"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.gith... | 4 | 5 | 6 |
833996f2b9c31a2f3851f8ad0f497a0f76bbc2fe | Adam Reichold | 2020-08-04T19:18:33 | Remove fallback to word-sized atomics as we explicitly detect the available atomics now. | diff --git a/build.rs b/build.rs
index fb7c6c5..3f9e906 100644
--- a/build.rs
+++ b/build.rs
@@ -4,22 +4,13 @@ fn main() {
let ac = autocfg::new();
for root in &["core", "std"] {
- ac.emit_path_cfg(
- &format!("{}::sync::atomic::AtomicUsize", root),
- "has_atomic_usize",
- ... | 3 | 16 | 106 |
7db30b4f1ba1b7953023734ae20cb5ba34c120a9 | Adam Reichold | 2020-08-02T06:20:07 | Port the fetch_update implementation from the standard library. | diff --git a/src/lib.rs b/src/lib.rs
index d6b19a6..f66e487 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -228,6 +228,62 @@ impl<T: Copy> Atomic<T> {
) -> Result<T, T> {
unsafe { ops::atomic_compare_exchange_weak(self.v.get(), current, new, success, failure) }
}
+
+ /// Fetches the value, and applie... | 1 | 56 | 0 |
e52d9075341c4421f492e9c49a05b48068d8bb54 | Amanieu d'Antras | 2020-07-05T07:46:40 | Bump version to 0.4.6 | diff --git a/Cargo.toml b/Cargo.toml
index e00120b..0e14093 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.4.5"
+version = "0.4.6"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.git... | 1 | 1 | 1 |
e9ee099123e4ae61ef9c2ab5f57188950ae64383 | Jasen Borisov | 2020-07-04T23:17:56 | ops.rs: fix compiler error from missing imports
only import the types that are supported by the compile target | diff --git a/src/ops.rs b/src/ops.rs
index dad5a60..3626c9e 100644
--- a/src/ops.rs
+++ b/src/ops.rs
@@ -12,10 +12,14 @@ use core::ops;
use core::sync::atomic::Ordering;
use fallback;
-#[cfg(feature = "nightly")]
-use core::sync::atomic::{
- AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicU16, AtomicU32, Atomic... | 1 | 8 | 4 |
b8b900f26bdaa9746b9a9c70539eb5429ca524d2 | Hadrien G | 2019-09-05T22:23:13 | Apply review recommendations | diff --git a/src/lib.rs b/src/lib.rs
index 0d78da9..d6b19a6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -31,20 +31,15 @@
//! are often used for lazy global initialization.
#![warn(missing_docs)]
-#![cfg_attr(
- not(feature = "std"), no_std
-)]
+#![no_std]
#![cfg_attr(
feature = "nightly", feature(const_fn,... | 1 | 2 | 8 |
973c055f82e75dd8b78912ab9b3f873471d7919c | Hadrien G | 2019-09-05T22:17:55 | Provide a RefUnwindSafe implementation when 'std' feature is enabled | diff --git a/Cargo.toml b/Cargo.toml
index 16d0f66..e00120b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,3 +11,4 @@ keywords = ["atomic", "no_std"]
[features]
nightly = []
+std = []
diff --git a/src/lib.rs b/src/lib.rs
index d75fe8e..0d78da9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -31,21 +31,29 @@
//! are o... | 2 | 21 | 2 |
1faf633024a3aa93f03b12192efd7c2fabd1e8d6 | Amanieu d'Antras | 2019-05-16T19:32:52 | Bump version to 0.4.5 | diff --git a/Cargo.toml b/Cargo.toml
index 6f89d49..16d0f66 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.4.4"
+version = "0.4.5"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.git... | 1 | 1 | 1 |
13bf2ba36c36b185adbc0003a77f66316b07960d | MSxDOS | 2019-05-16T16:49:39 | Fix description | diff --git a/src/lib.rs b/src/lib.rs
index 6f75842..d75fe8e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -114,7 +114,7 @@ impl<T: Copy> Atomic<T> {
ops::atomic_is_lock_free::<T>()
}
- /// Returns a mutable reference to the underlying integer.
+ /// Returns a mutable reference to the underlying type... | 1 | 1 | 1 |
2def863339b007317054e3febb3cb5fb076efb4b | MSxDOS | 2019-05-16T13:27:41 | Add 'get_mut' and 'into_inner' methods | diff --git a/src/lib.rs b/src/lib.rs
index a8ad0b9..6f75842 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -114,6 +114,24 @@ impl<T: Copy> Atomic<T> {
ops::atomic_is_lock_free::<T>()
}
+ /// Returns a mutable reference to the underlying integer.
+ ///
+ /// This is safe because the mutable referen... | 1 | 18 | 0 |
44c9d899b4bb9acaae1ca012a1ab574cc7f61718 | M Farkas-Dyck | 2018-10-03T01:50:13 | repr(transparent) | diff --git a/src/lib.rs b/src/lib.rs
index a8ad0b9..3eb5b99 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -51,6 +51,7 @@ mod ops;
/// A generic atomic wrapper type which allows an object to be safely shared
/// between threads.
+#[repr(transparent)]
pub struct Atomic<T: Copy> {
v: UnsafeCell<T>,
} | 1 | 1 | 0 |
94bbce42eb4a06b3ec21d0340062fd602117aa67 | Amanieu d'Antras | 2019-02-22T19:47:35 | Bump version to 0.4.4 | diff --git a/Cargo.toml b/Cargo.toml
index 13e71aa..6f89d49 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.4.3"
+version = "0.4.4"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.git... | 1 | 1 | 1 |
0d656180cfda9a035366932adcc0e24ea93f5e30 | Kevin Boos | 2019-02-22T19:32:30 | update for latest nightly that changes integer_atomics | diff --git a/src/fallback.rs b/src/fallback.rs
index aa95c1f..8b7e861 100644
--- a/src/fallback.rs
+++ b/src/fallback.rs
@@ -11,7 +11,7 @@ use core::num::Wrapping;
use core::ops;
use core::ptr;
use core::slice;
-use core::sync::atomic::{self, AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
+use core::sync::atomic::{self,... | 2 | 3 | 3 |
f620658d7299110885406ef16bcdf78b8496c8fb | Amanieu d'Antras | 2019-01-14T17:44:22 | Bump version to 0.4.3 | diff --git a/Cargo.toml b/Cargo.toml
index 7d43262..13e71aa 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.4.2"
+version = "0.4.3"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.git... | 1 | 1 | 1 |
b0622d50ed2f1241b6d52821c1f0facb8a5675da | Amanieu d'Antras | 2019-01-14T17:43:43 | Update for latest nightly
Fixes #7 | diff --git a/src/lib.rs b/src/lib.rs
index 9f968c5..02cd863 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -33,7 +33,7 @@
#![warn(missing_docs)]
#![no_std]
#![cfg_attr(
- feature = "nightly", feature(const_fn, const_int_ops, const_let, cfg_target_has_atomic, integer_atomics, atomic_min_max)
+ feature = "nightly",... | 1 | 1 | 1 |
dda6dde4c5bf72c234142fcfb820224a8d41d27b | Amanieu d'Antras | 2018-12-09T15:58:34 | Bump version to 0.4.2 | diff --git a/Cargo.toml b/Cargo.toml
index 58de88b..7d43262 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.4.1"
+version = "0.4.2"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.git... | 1 | 1 | 1 |
fbf6783ddd747465817f87e62166effcccaffabc | Peter Gerber | 2018-12-09T12:32:28 | Fix compile error when nightly feature is enabled
Stop using the && operator in const functions. It not yet allowed there.
The error:
$ cargo +nightly build --features nightly
Compiling atomic v0.4.1 (/home/user/src/atomic-rs)
error[E0019]: constant function contains unimplemented expression type
--> src/ops.rs... | diff --git a/src/ops.rs b/src/ops.rs
index 06bce44..dad5a60 100644
--- a/src/ops.rs
+++ b/src/ops.rs
@@ -28,7 +28,8 @@ const ALIGNOF_USIZE: usize = mem::align_of::<usize>();
#[inline]
pub const fn atomic_is_lock_free<T>() -> bool {
let size = mem::size_of::<T>();
- 1 == size.count_ones() && 8 >= size && mem::... | 1 | 2 | 1 |
40eaa047c57b178b79a70ea46e00a8fb0b2acbdb | Amanieu d'Antras | 2018-07-30T09:05:59 | Bump version to 0.4.1 | diff --git a/Cargo.toml b/Cargo.toml
index b879269..58de88b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.4.0"
+version = "0.4.1"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.git... | 1 | 1 | 1 |
b77eb3f36f9a01355686923dfeeb67bfc8a664a3 | M Farkas-Dyck | 2018-07-30T08:48:27 | const fn is_lock_free | diff --git a/src/lib.rs b/src/lib.rs
index 331d916..9f968c5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -33,7 +33,7 @@
#![warn(missing_docs)]
#![no_std]
#![cfg_attr(
- feature = "nightly", feature(const_fn, cfg_target_has_atomic, integer_atomics, atomic_min_max)
+ feature = "nightly", feature(const_fn, const_i... | 2 | 23 | 29 |
d606b09bdf61bb307cb4759b7ad722f1e9210e12 | Amanieu d'Antras | 2018-06-21T16:02:39 | Add fetch_min and fetch_max operations | diff --git a/src/fallback.rs b/src/fallback.rs
index f1d3b84..aa95c1f 100644
--- a/src/fallback.rs
+++ b/src/fallback.rs
@@ -5,12 +5,13 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
+use core::cmp;
use core::mem;... | 3 | 397 | 12 |
0580d7371ac4939ee513e17d881b3f7c9ea21fe6 | Amanieu d'Antras | 2018-06-21T15:42:42 | Add extended atomic ops for isize and i128 | diff --git a/src/lib.rs b/src/lib.rs
index 89e7888..2ea74ff 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -44,8 +44,8 @@ pub use core::sync::atomic::{fence, Ordering};
use core::cell::UnsafeCell;
use core::fmt;
-mod ops;
mod fallback;
+mod ops;
/// A generic atomic wrapper type which allows an object to be safely... | 1 | 53 | 4 |
b232db0350100894d476441686362f2db68d25de | Amanieu d'Antras | 2018-06-21T15:27:38 | Unify the nightly and stable implementations | diff --git a/src/lib.rs b/src/lib.rs
index 5743d02..89e7888 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -32,8 +32,7 @@
#![warn(missing_docs)]
#![no_std]
-#![cfg_attr(feature = "nightly", feature(const_fn, extended_compare_and_swap))]
-#![cfg_attr(feature = "nightly", feature(cfg_target_has_atomic, integer_atomics))... | 3 | 134 | 232 |
fd59766cb0d35270a178fda1824ad6a778541ce2 | Amanieu d'Antras | 2018-06-21T15:11:39 | Reorganize spinlock array to eliminate false sharing
Fixes #1 | diff --git a/src/fallback.rs b/src/fallback.rs
index 20f1f60..f1d3b84 100644
--- a/src/fallback.rs
+++ b/src/fallback.rs
@@ -10,7 +10,28 @@ use core::num::Wrapping;
use core::ops;
use core::ptr;
use core::slice;
-use core::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT};
+use core::sync::atomic::{self, Orderi... | 1 | 27 | 25 |
9b7bb73045bd9d9ba521bc16e96767e3ed6fc4cc | Amanieu d'Antras | 2017-07-07T20:17:22 | Bump version to 0.3.4 | diff --git a/Cargo.toml b/Cargo.toml
index ff9cb26..6843839 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.3.3"
+version = "0.3.4"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.git... | 1 | 1 | 1 |
04e1b4ccb9926ae405a7b00b96d4b680eb19c434 | Vadim Petrochenkov | 2017-07-07T20:12:10 | Fix build on nightly | diff --git a/src/nightly.rs b/src/nightly.rs
index fbe258e..5fdb37f 100644
--- a/src/nightly.rs
+++ b/src/nightly.rs
@@ -10,6 +10,7 @@ use core::ops;
use core::num::Wrapping;
use core::sync::atomic::{AtomicU8, AtomicU16, AtomicU32, AtomicU64, Ordering};
+#[path = "fallback.rs"]
mod fallback;
#[inline]
diff --gi... | 2 | 2 | 0 |
394bba9e46eaa59a16c3785a03379817418c5f58 | Amanieu d'Antras | 2016-05-12T22:03:19 | Bump version to 0.3.3 | diff --git a/Cargo.toml b/Cargo.toml
index 9916954..ff9cb26 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.3.2"
+version = "0.3.3"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.git... | 1 | 1 | 1 |
c61c1f21acfba81acc1bde40595cc78894412be0 | Amanieu d'Antras | 2016-05-12T22:02:52 | Use new integer atomic types on nightly instead of intrinsics | diff --git a/src/lib.rs b/src/lib.rs
index 73a93f2..7021aca 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -32,8 +32,8 @@
#![warn(missing_docs)]
#![no_std]
-#![cfg_attr(feature = "nightly", feature(core_intrinsics, const_fn,
- extended_compare_and_swap, cfg_target_has_atomic))]
... | 2 | 99 | 237 |
42ae76c9cb5e7a7a8ef7d4e8314bba286249e2d3 | Amanieu d'Antras | 2016-05-12T21:41:48 | Bump version to 0.3.2 | diff --git a/Cargo.toml b/Cargo.toml
index 74dc088..9916954 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.3.1"
+version = "0.3.2"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.git... | 1 | 1 | 1 |
36aeade7f8176a0a02e41e3d761190887314ff43 | Amanieu d'Antras | 2016-05-12T21:40:59 | Fix Atomic<bool> on nightly | diff --git a/src/nightly.rs b/src/nightly.rs
index c6c31ca..e3a223a 100644
--- a/src/nightly.rs
+++ b/src/nightly.rs
@@ -315,13 +315,21 @@ pub unsafe fn atomic_add<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T
{
match mem::size_of::<T>() {
#[cfg(target_has_atomic = "8")]
- 1 => atomic_add_ra... | 1 | 60 | 20 |
a73631511ddc613216942000762a1cf7b010afde | Amanieu d'Antras | 2016-05-12T21:34:55 | Use cfg(target_has_atomic) on nightly | diff --git a/src/lib.rs b/src/lib.rs
index c7a8a82..73a93f2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -32,7 +32,8 @@
#![warn(missing_docs)]
#![no_std]
-#![cfg_attr(feature = "nightly", feature(core_intrinsics, const_fn, extended_compare_and_swap))]
+#![cfg_attr(feature = "nightly", feature(core_intrinsics, const_... | 2 | 68 | 22 |
1fe3064321595e3f0e9998bb7d13e21e747ae3cb | Amanieu d'Antras | 2016-04-02T12:20:15 | Bump version to 0.3.1 | diff --git a/Cargo.toml b/Cargo.toml
index 59621e6..74dc088 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "atomic"
-version = "0.3.0"
+version = "0.3.1"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Generic Atomic<T> wrapper type"
documentation = "https://amanieu.git... | 1 | 1 | 1 |
fa2304e76d051c40383424b4fb2c48446ad042cd | Amanieu d'Antras | 2016-04-02T12:19:02 | Use proper target_arch on x86 | diff --git a/src/lib.rs b/src/lib.rs
index 3d43dfd..c7a8a82 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -344,7 +344,7 @@ mod tests {
assert_eq!(Atomic::<i64>::is_lock_free(),
cfg!(any(target_pointer_width = "64",
all(feature = "nightly",
- ... | 2 | 12 | 12 |
570bad3051e384f13d7156dd4217ebb03bfd6a98 | Brennan Kinney | 2026-01-10T03:33:22 | docs: Switch to `thread::scope` for example | diff --git a/src/lib.rs b/src/lib.rs
index 01a80a8..9be72e0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -40,25 +40,24 @@
//!
//! ```rust
//! use thread_local::ThreadLocal;
-//! use std::sync::Arc;
//! use std::cell::Cell;
//! use std::thread;
//!
-//! let tls = Arc::new(ThreadLocal::new());
+//! let tls = ThreadL... | 1 | 10 | 11 |
33f151b641a1b099b440c062bacb1237a194a454 | Newton Ni | 2025-09-24T14:36:40 | Fix integer underflow in `RawIter::size_hint` | diff --git a/src/lib.rs b/src/lib.rs
index 201ca5c..01a80a8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -484,11 +484,21 @@ impl RawIter {
fn size_hint<T: Send>(&self, thread_local: &ThreadLocal<T>) -> (usize, Option<usize>) {
let total = thread_local.values.load(Ordering::Relaxed);
- (total - sel... | 1 | 11 | 1 |
9625519398908188bf8584b5ff57a8c43eaee4a4 | james7132 | 2025-08-20T01:17:59 | Fix warning | diff --git a/src/lib.rs b/src/lib.rs
index c4d1d5b..201ca5c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -165,7 +165,8 @@ impl<T: Send> Drop for ThreadLocal<T> {
}
impl<T: Send> ThreadLocal<T> {
- const NULL_BUCKET: AtomicPtr<Entry<T>> = AtomicPtr::new(std::ptr::null_mut());
+ #[allow(clippy::declare_interior_... | 1 | 2 | 1 |
b7de33604770522c7f19c065e29b8feeeb201e77 | james7132 | 2025-08-20T01:16:54 | Fix MSRV build | diff --git a/src/lib.rs b/src/lib.rs
index 86c88f7..c4d1d5b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -165,10 +165,12 @@ impl<T: Send> Drop for ThreadLocal<T> {
}
impl<T: Send> ThreadLocal<T> {
+ const NULL_BUCKET: AtomicPtr<Entry<T>> = AtomicPtr::new(std::ptr::null_mut());
+
/// Creates a new empty `Thre... | 1 | 4 | 2 |
2f13299130545ad41d910ebbad7e77ec7ecac221 | james7132 | 2025-08-20T00:35:13 | Shrink unsafe block size and extra empty lines | diff --git a/src/lib.rs b/src/lib.rs
index bf87029..86c88f7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -201,8 +201,9 @@ impl<T: Send> ThreadLocal<T> {
where
F: FnOnce() -> T,
{
+ let result = self.get_or_try(|| Ok::<T, ()>(create()));
// SAFETY: The provided closure will never return... | 1 | 9 | 1 |
55d1d771e2dd7578de774711459a27e61572357e | james7132 | 2025-08-20T00:17:11 | Formatting | diff --git a/src/lib.rs b/src/lib.rs
index e347f9c..bf87029 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -269,7 +269,7 @@ impl<T: Send> ThreadLocal<T> {
};
// Insert the new element into the bucket
- // SAFETY:
+ // SAFETY:
// - Any allocation larger than isize::MAX bytes woul... | 1 | 1 | 1 |
0de70f23c63f210d57a59861ab08ded5cdc0e663 | james7132 | 2025-08-20T00:15:53 | Update safety comments | diff --git a/src/lib.rs b/src/lib.rs
index 3ec2792..e347f9c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -225,12 +225,13 @@ impl<T: Send> ThreadLocal<T> {
if bucket_ptr.is_null() {
return None;
}
- // SAFETY: Any allocation larger than isize::MAX bytes would fail to
- // allo... | 1 | 21 | 18 |
fa80973a24e46d146b077ceddff8ede2fec2802d | james7132 | 2025-08-20T00:12:19 | Formatting | diff --git a/src/lib.rs b/src/lib.rs
index 0116da6..3ec2792 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -221,7 +221,7 @@ impl<T: Send> ThreadLocal<T> {
}
fn get_inner(&self, thread: Thread) -> Option<&T> {
- let bucket_ptr =self.get_bucket(thread).load(Ordering::Acquire);
+ let bucket_ptr = se... | 1 | 1 | 1 |
a7f985dd6fae63f31a90508d3c41b8bfe6757ece | James Liu | 2025-08-20T00:11:35 | Apply suggestions from code review
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com> | diff --git a/src/lib.rs b/src/lib.rs
index eedacbb..0116da6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -181,7 +181,7 @@ impl<T: Send> ThreadLocal<T> {
let mut buckets = [const { AtomicPtr::new(ptr::null_mut()) }; BUCKETS];
for (i, bucket) in buckets[..allocated_buckets].iter_mut().enumerate() {
- ... | 1 | 1 | 1 |
8464c32d8bd35f720d2bac107600ae266b98207c | james7132 | 2025-08-19T16:04:43 | Review feedback | diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..64965e7
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cfg-if"
+version = "1.0.1"
+source = "registry+https://github... | 2 | 34 | 27 |
260735e052ccce35189d45318fd2b3144d4ca8ab | james7132 | 2025-08-04T06:38:40 | Remove unnecessary needs_drop check | diff --git a/src/lib.rs b/src/lib.rs
index c1d0cd8..596c565 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -124,7 +124,7 @@ impl<T> Entry<T> {
impl<T> Drop for Entry<T> {
fn drop(&mut self) {
- if std::mem::needs_drop::<T>() && *self.present.get_mut() {
+ if *self.present.get_mut() {
// ... | 1 | 1 | 1 |
0ef2cb8a3ef90af0ae1b4e8cb3be840ffa444664 | james7132 | 2025-08-04T06:09:31 | Revert changes to allocation. | diff --git a/src/lib.rs b/src/lib.rs
index 3bb91b5..c1d0cd8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -259,23 +259,23 @@ impl<T: Send> ThreadLocal<T> {
let bucket_ptr = if bucket_ptr.is_null() {
let new_bucket = allocate_bucket(thread.bucket_size);
- bucket_atomic_ptr
- ... | 1 | 13 | 13 |
ff042bbe3a713ccd6c0b0e99e331c79a960c41fa | james7132 | 2025-08-04T06:03:53 | Gratuitous safety comments | diff --git a/src/lib.rs b/src/lib.rs
index cd3c86c..3bb91b5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -106,17 +106,39 @@ struct Entry<T> {
value: UnsafeCell<MaybeUninit<T>>,
}
+impl<T> Entry<T> {
+ fn get_value_cell(&self) -> Option<&UnsafeCell<MaybeUninit<T>>> {
+ self.present.load(Ordering::Acquir... | 1 | 99 | 40 |
a2afa31b9dc26dfdf19af69f554bc9e7118555fb | james7132 | 2025-08-04T04:06:55 | Start writing safety comments | diff --git a/src/lib.rs b/src/lib.rs
index 5cc153c..cd3c86c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -64,7 +64,8 @@
//! ```
#![warn(missing_docs)]
-#![allow(clippy::mutex_atomic)]
+#![warn(clippy::undocumented_unsafe_blocks)]
+#![warn(unsafe_op_in_unsafe_fn)]
#![cfg_attr(feature = "nightly", feature(thread_loca... | 1 | 43 | 6 |
cb3bd3e55e032ea8e7f2258893d2ba90606e152b | james7132 | 2025-08-03T23:40:56 | Use MaybeUninit::asssume_init_{mut, ref} | diff --git a/src/lib.rs b/src/lib.rs
index 8c7a450..5cc153c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -208,7 +208,7 @@ impl<T: Send> ThreadLocal<T> {
unsafe {
let entry = &*bucket_ptr.add(thread.index);
if entry.present.load(Ordering::Relaxed) {
- Some(&*(&*entry.valu... | 1 | 4 | 4 |
89584834883df6502a4b77753645ab7d130d6deb | james7132 | 2025-08-03T23:28:01 | Formatting and comments | diff --git a/src/thread_id.rs b/src/thread_id.rs
index 852b4e9..c36bcb4 100644
--- a/src/thread_id.rs
+++ b/src/thread_id.rs
@@ -64,16 +64,15 @@ impl Thread {
let bucket_size = 1 << bucket;
let index = id - (bucket_size - 1);
- Self {
- bucket,
- index,
- }
+ ... | 1 | 3 | 4 |
ef4caf52d6cbf33a9b0f09c37cf5b16244c9db98 | james7132 | 2025-08-03T23:12:13 | Shrink Thread | diff --git a/src/lib.rs b/src/lib.rs
index 5cc4728..3c04038 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -235,7 +235,7 @@ impl<T: Send> ThreadLocal<T> {
// If the bucket doesn't already exist, we need to allocate it
let bucket_ptr = if bucket_ptr.is_null() {
- let new_bucket = allocate_buc... | 2 | 21 | 19 |
f8493534e03d233890c405396e18bafefe7c7599 | james7132 | 2025-08-03T22:19:15 | Don't change the criterion version | diff --git a/benches/Cargo.toml b/benches/Cargo.toml
index 15d7a47..8b3d99e 100644
--- a/benches/Cargo.toml
+++ b/benches/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
edition = "2021"
[dependencies]
-criterion = { version = "0.6.0", features = ["html_reports"] }
+criterion = "0.5.1"
[dev-dependencies... | 1 | 1 | 1 |
fff13cb81e9f05dbc2c532df0e692c1419c90027 | james7132 | 2025-08-03T22:15:21 | Fix benches' Cargo.toml | diff --git a/benches/Cargo.toml b/benches/Cargo.toml
index a4d9b15..15d7a47 100644
--- a/benches/Cargo.toml
+++ b/benches/Cargo.toml
@@ -1,9 +1,10 @@
[package]
name = "benches"
-edition = "2024"
-description = "Benchmarks that test Bevy's performance"
+description = "Benchmarks that test thread_local's performance"
... | 1 | 3 | 2 |
b7690b126ec8e492129277b75264737e3af574a3 | james7132 | 2025-08-03T22:09:20 | Remove extra all() | diff --git a/src/thread_id.rs b/src/thread_id.rs
index 9cbab23..c1bca0f 100644
--- a/src/thread_id.rs
+++ b/src/thread_id.rs
@@ -77,7 +77,7 @@ impl Thread {
}
cfg_if::cfg_if! {
- if #[cfg(all(feature = "nightly"))] {
+ if #[cfg(feature = "nightly")] {
// This is split into 2 thread-local variables so... | 1 | 1 | 1 |
b951cde530f14f1beb1437ee2934dacb726621ac | james7132 | 2025-08-03T21:00:32 | Fix formatting | diff --git a/src/lib.rs b/src/lib.rs
index 89cb9b0..8c7a450 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -181,10 +181,7 @@ impl<T: Send> ThreadLocal<T> {
where
F: FnOnce() -> T,
{
- unsafe {
- self.get_or_try(|| Ok::<T, ()>(create()))
- .unwrap_unchecked()
- }
+... | 1 | 1 | 4 |
0eb8c2bc2afbfd0ed2f505d17fed1f46762f17c3 | james7132 | 2025-08-03T20:57:11 | MSRV-based cleanup | diff --git a/src/cached.rs b/src/cached.rs
index 2daba4d..e74b6af 100644
--- a/src/cached.rs
+++ b/src/cached.rs
@@ -3,7 +3,6 @@
use super::{IntoIter, IterMut, ThreadLocal};
use std::fmt;
use std::panic::UnwindSafe;
-use std::usize;
/// Wrapper around [`ThreadLocal`].
///
@@ -62,7 +61,7 @@ impl<T: Send> CachedTh... | 4 | 7 | 76 |
f9ca3d375745c14a632ae3ffe6a7a646dc8421a0 | Conrad Ludgate | 2025-07-20T18:57:04 | do not register a thread-local destructor in ThreadLocal::get | diff --git a/src/lib.rs b/src/lib.rs
index 4d78ed4..5cc4728 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -182,7 +182,7 @@ impl<T: Send> ThreadLocal<T> {
/// Returns the element for the current thread, if it exists.
pub fn get(&self) -> Option<&T> {
- self.get_inner(thread_id::get())
+ thread_id... | 2 | 15 | 1 |
adb21b8b85c5224e7d766d4975b9ce2d9aaf26b5 | leopardracer | 2025-06-16T13:07:08 | Update cached.rs | diff --git a/src/cached.rs b/src/cached.rs
index 16f6516..2daba4d 100644
--- a/src/cached.rs
+++ b/src/cached.rs
@@ -69,7 +69,7 @@ impl<T: Send> CachedThreadLocal<T> {
}
/// Removes all thread-specific values from the `ThreadLocal`, effectively
- /// reseting it to its original state.
+ /// resetting ... | 1 | 1 | 1 |
2a55b9606711b97c26e8327a0d83a3b36a312e0a | leopardracer | 2025-06-16T13:06:49 | Update lib.rs | diff --git a/src/lib.rs b/src/lib.rs
index c6ae686..4d78ed4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -295,7 +295,7 @@ impl<T: Send> ThreadLocal<T> {
}
/// Removes all thread-specific values from the `ThreadLocal`, effectively
- /// reseting it to its original state.
+ /// resetting it to its origin... | 1 | 1 | 1 |
7ef899314f849c77ee64f877ac09afce592ad5a2 | Amanieu d'Antras | 2024-02-20T21:12:58 | Bump version to 1.1.8 | diff --git a/Cargo.toml b/Cargo.toml
index 8df4fde..d63ea87 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "1.1.7"
+version = "1.1.8"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://docs... | 1 | 1 | 1 |
bd8410a2f6269882bb8724af6770bb3e50b869ea | Arpad Borsos | 2024-02-07T22:50:39 | Make `new` a `const fn`
This removes the initial capacity of `2` and rather makes `new` a `const fn`. | diff --git a/src/lib.rs b/src/lib.rs
index d8c39b2..c6ae686 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -153,8 +153,12 @@ impl<T: Send> Drop for ThreadLocal<T> {
impl<T: Send> ThreadLocal<T> {
/// Creates a new empty `ThreadLocal`.
- pub fn new() -> ThreadLocal<T> {
- Self::with_capacity(2)
+ pub c... | 1 | 6 | 2 |
b197719f9f4972af620989bcfe39ef60ac8e8605 | Arpad Borsos | 2024-02-07T23:04:16 | Do not early return on null `bucket_ptr`
Buckets are allocated on demand based on `Thread::bucket`.
This means that when only threads with a high `id` (and thus high `bucket`) are writing entries into the `ThreadLocal`,
only higher `buckets` will be allocated, and lower buckets will be `null`.
Thus we must not early-... | diff --git a/src/lib.rs b/src/lib.rs
index a92f272..16b39bc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -143,7 +143,7 @@ impl<T: Send> Drop for ThreadLocal<T> {
let this_bucket_size = 1 << i;
if bucket_ptr.is_null() {
- break;
+ continue;
}
... | 2 | 48 | 26 |
0f6c70514922bfc34c2297ef4bbe96330dfba856 | james7132 | 2024-02-20T07:23:46 | std::hint::black_box is not stable until 1.66 | diff --git a/src/lib.rs b/src/lib.rs
index e97d68f..9ae10d8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -526,7 +526,6 @@ unsafe fn deallocate_bucket<T>(bucket: *mut Entry<T>, size: usize) {
mod tests {
use super::ThreadLocal;
use std::cell::RefCell;
- use std::hint::black_box;
use std::sync::atomic::... | 1 | 2 | 3 |
66a0d00e81bd386d70607ed009d74eae866bdd30 | james7132 | 2024-02-20T05:02:13 | Formatting and addressing review comments | diff --git a/src/lib.rs b/src/lib.rs
index b31b1d7..e97d68f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -216,7 +216,7 @@ impl<T: Send> ThreadLocal<T> {
}
unsafe {
let entry = &*bucket_ptr.add(thread.index);
- if entry.present.load(Ordering::Acquire) {
+ if entry.pres... | 1 | 2 | 2 |
8c739d00c8abe4b52bf07d01de36fa353623b196 | james7132 | 2024-02-18T07:23:38 | Add regression test for miri | diff --git a/src/lib.rs b/src/lib.rs
index 301e6f1..b31b1d7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -529,6 +529,7 @@ mod tests {
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::Relaxed;
use std::sync::Arc;
+ use std::hint::black_box;
use std::thread;
fn make_create... | 1 | 23 | 0 |
9a2214eb5eb55f037a2217ca9da9e3dffb3a960d | james7132 | 2024-02-16T20:12:07 | Replace non-atomic load with an atomic one | diff --git a/src/lib.rs b/src/lib.rs
index a92f272..301e6f1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -216,8 +216,7 @@ impl<T: Send> ThreadLocal<T> {
}
unsafe {
let entry = &*bucket_ptr.add(thread.index);
- // Read without atomic operations as only this thread can set the val... | 1 | 1 | 2 |
8a975cb0f8ebde3d88ed30716883a5a65801fb2f | threadexception | 2023-06-15T14:25:35 | New bucket layout | diff --git a/src/lib.rs b/src/lib.rs
index b7902b3..a92f272 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -94,13 +94,14 @@ const POINTER_WIDTH: u8 = 32;
const POINTER_WIDTH: u8 = 64;
/// The total number of buckets stored in each thread local.
-const BUCKETS: usize = (POINTER_WIDTH + 1) as usize;
+/// All buckets com... | 2 | 26 | 41 |
4e3fea1c1d3407524c6ac54e81a9356e975c7e7c | terrarier2111 | 2023-05-08T13:22:11 | Undo changes to size_hint | diff --git a/src/lib.rs b/src/lib.rs
index ba20be2..b7902b3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -441,13 +441,7 @@ impl RawIter {
fn size_hint<T: Send>(&self, thread_local: &ThreadLocal<T>) -> (usize, Option<usize>) {
let total = thread_local.values.load(Ordering::Acquire);
- // max calcul... | 1 | 1 | 7 |
9b6d316244aabfcdf9d077194097e4b6ced1b8b9 | terrarier2111 | 2023-04-17T13:38:09 | More early return, improve size_hint | diff --git a/src/lib.rs b/src/lib.rs
index 149d1fb..ba20be2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -384,14 +384,16 @@ impl RawIter {
let bucket = unsafe { thread_local.buckets.get_unchecked(self.bucket) };
let bucket = bucket.load(Ordering::Acquire);
- if !bucket.is_null() {
... | 1 | 27 | 17 |
827be1f1aa52058622ecd1f63946f072010e942a | terrarier2111 | 2023-04-15T10:56:12 | Stop checking guaranteed null buckets | diff --git a/src/lib.rs b/src/lib.rs
index 12d25f6..149d1fb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -147,7 +147,7 @@ impl<T: Send> Drop for ThreadLocal<T> {
}
if bucket_ptr.is_null() {
- continue;
+ break;
}
unsafe { deallocate_bu... | 1 | 1 | 1 |
43c33374a19ee38f0845e48280b445d5c77e3e77 | Dirkjan Ochtman | 2023-02-17T20:08:50 | Set rust-version in Cargo metadata | diff --git a/Cargo.toml b/Cargo.toml
index 56d301c..3610912 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,6 +9,7 @@ repository = "https://github.com/Amanieu/thread_local-rs"
readme = "README.md"
keywords = ["thread_local", "concurrent", "thread"]
edition = "2021"
+rust-version = "1.59"
[features]
# this feature... | 1 | 1 | 0 |
d9c6ff3e751408c3f2e58b15dcc047e3669b9292 | Amanieu d'Antras | 2023-02-12T16:15:53 | Bump version to 1.1.7 | diff --git a/Cargo.toml b/Cargo.toml
index 7a860e6..56d301c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "1.1.6"
+version = "1.1.7"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://docs... | 1 | 1 | 1 |
4315fdf1175cad068ff3d8ccd1a876bc6955c7cc | Amanieu d'Antras | 2023-02-12T16:14:58 | Properly handle arbitrary TLS destruction order
Fixes #47 | diff --git a/src/thread_id.rs b/src/thread_id.rs
index 54bb84a..aa4f2d6 100644
--- a/src/thread_id.rs
+++ b/src/thread_id.rs
@@ -7,6 +7,7 @@
use crate::POINTER_WIDTH;
use once_cell::sync::Lazy;
+use std::cell::Cell;
use std::cmp::Reverse;
use std::collections::BinaryHeap;
use std::sync::Mutex;
@@ -81,19 +82,25 @... | 1 | 28 | 15 |
905dad591e1846a360df8cb309a194a91126e0f8 | Amanieu d'Antras | 2023-02-10T01:37:04 | Bump version to 1.1.6 | diff --git a/Cargo.toml b/Cargo.toml
index ac6b7d2..7a860e6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "1.1.5"
+version = "1.1.6"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://docs... | 1 | 1 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.