WRC
A thread-safe weighted reference counting smart-pointer for Rust.
Overview
By using weights instead of direct reference counting WRC requires roughly half as many synchronisation operations and writes to the heap. Every time a WRC is cloned it's weight is split in two, with half allocated to the parent and half allocated to the child. When a WRC is dropped it's weight is removed from the total. When the total weight declines to zero then the referenced object is dropped.
Features
- Thread-safe.
- Efficient.
- Lightweight.
Examples
Sharing some immutable data between threads:
use WRC;
use thread;
let five = WRC new;
for _ in 0..10
Sharing a mutable AtomicUsize
:
use WRC;
use ;
use thread;
let val = WRC new;
for _ in 0..10
Status
This create relies on the (currently) unstable shared
, unsize
and coerce_unsized
features, meaning that you need to run an unstable Rust. Other than that it seems legit.
License
Source code is licensed under the terms of the MIT license, the text of which is included in the LICENSE file in this distribution.