Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions arcshift/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.4.0

`ArcShift<T>` now implements `Default` if `T:Default`.
2 changes: 1 addition & 1 deletion arcshift/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down
3 changes: 1 addition & 2 deletions arcshift/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use core::ops::Deref;
/// a non-threadsafe `ArcShiftCellHandle<T>`. 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<T: 'static + ?Sized> {
// UnsafeCell makes ArcShiftCell invariant, which it needs to be
inner: UnsafeCell<ArcShift<T>>,
Expand Down
9 changes: 8 additions & 1 deletion arcshift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`]).
Expand Down Expand Up @@ -416,6 +417,12 @@ where
}
}

impl<T: Default> Default for ArcShift<T> {
fn default() -> Self {
ArcShift::new(Default::default())
}
}

impl<T: ?Sized> Debug for ArcShiftWeak<T>
where
T: Debug,
Expand Down