diff --git a/arcshift/CHANGELOG.md b/arcshift/CHANGELOG.md new file mode 100644 index 0000000..6763eaa --- /dev/null +++ b/arcshift/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.4.0 + +`ArcShift` now implements `Default` if `T:Default`. diff --git a/arcshift/Cargo.toml b/arcshift/Cargo.toml index d9969da..46bc23c 100644 --- a/arcshift/Cargo.toml +++ b/arcshift/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "arcshift" -version = "0.3.1" +version = "0.4.0" documentation = "https://docs.rs/arcshift/" homepage = "https://github.com/avl/arcshift/" repository = "https://github.com/avl/arcshift/" diff --git a/arcshift/src/cell.rs b/arcshift/src/cell.rs index a8ecf64..843599f 100644 --- a/arcshift/src/cell.rs +++ b/arcshift/src/cell.rs @@ -12,8 +12,7 @@ use core::ops::Deref; /// a non-threadsafe `ArcShiftCellHandle`. This handle implements Deref, giving access /// to the pointed to &T. This handle should not be leaked, /// but if it is leaked, the effect is that whatever value the ArcShiftCell-instance -/// pointed to at that time, will forever leak also. All the linked-list nodes from -/// that entry and onward will also leak. So make sure to not leak the handle! +/// pointed to at that time, will forever leak also. pub struct ArcShiftCell { // UnsafeCell makes ArcShiftCell invariant, which it needs to be inner: UnsafeCell>, diff --git a/arcshift/src/lib.rs b/arcshift/src/lib.rs index d3822ff..366037a 100644 --- a/arcshift/src/lib.rs +++ b/arcshift/src/lib.rs @@ -71,7 +71,8 @@ //! inner value). ArcShift can still be used with only shared access ([`ArcShift::shared_get`]), //! and performance is still very good as long as the pointer is current. However, if //! the ArcShift instance is stale (needs reloading, because an update has occurred), reads will -//! be approximately twice as costly as for RwLock. +//! be approximately twice as costly as for RwLock. One mitigation for this is to use +//! [`cell::ArcShiftCell`]. However, this type is not `Sync`, only `Send`. //! * When modifying the value, the old version of the value lingers in memory until //! the last ArcShift that uses it has reloaded. Such a reload only happens when the ArcShift //! is accessed using a unique (`&mut`) access (like [`ArcShift::get`] or [`ArcShift::reload`]). @@ -416,6 +417,12 @@ where } } +impl Default for ArcShift { + fn default() -> Self { + ArcShift::new(Default::default()) + } +} + impl Debug for ArcShiftWeak where T: Debug,