Expand description
§shredder
shredder is a library providing a garbage collected smart pointer: Gc.
This is useful for times when you want shared access to some data, but the structure
of the data has unpredictable cycles in it. (So Arc would not be appropriate.)
shredder has the following features:
- safe: detects error conditions on the fly, and protects you from undefined behavior
- ergonomic: no need to manually manage roots, just a regular smart pointer
- deref support:
DerefGcgives you a garbage collected andDerefsmart pointer where possible - ready for fearless concurrency: works in multi-threaded contexts, with
AtomicGcfor cases where you need atomic operations - limited stop-the world: regular processing will rarely be interrupted
- seamless destruction: regular
dropfor'staticdata - clean finalization: optional
finalizefor non-'staticdata - concurrent collection: collection happens in the background, improving performance
- concurrent destruction: destructors are run in the background, improving performance
shredder has the following limitations:
- guarded access: accessing
Gcdata requires acquiring a guard (although you can useDerefGcin many cases to avoid this) - multiple collectors: only a single global collector is supported
- can’t handle
Rc/Arc: requires allGcobjects have straightforward ownership semantics - collection optimized for speed, not memory use:
Gcand internal metadata is small, but there is bloat during collection (will fix!) - no no-std support: The collector requires threading and other
stdfeatures (will fix!)
Modules§
- atomic
- Atomic gc operations
- marker
- Marker types
- plumbing
- Various types used for plumbing, stuff you don’t need to care about
- wrappers
- Helpful wrappers used for convenience methods
Macros§
- impl_
empty_ scan_ for_ send_ static - Implements an empty
Scanimplementation for aSend + 'statictype - mark_
send_ static_ gc_ safe - A
Send + 'statictype can be safely marked asGcSafe, and this macro eases that implementation
Structs§
- DerefGc
- A
Gc, but with the ability toDerefto its contents! - Gc
- A smart-pointer for data tracked by
shreddergarbage collector - GcGuard
- A guard object that lets you access the underlying data of a
Gc. It exists as data needs protection from being scanned while it’s being concurrently modified. - R
- A
GcSafeversion of&T - RMut
- A
GcSafeversion of&mut T - Scanner
- Scanner is a struct used to manage the scanning of data, sort of analogous to
HasherUsually you will only care about this while implementingScan
Traits§
- Finalize
- A trait implementing an alternative to
Drop, useful for non-GcDropdata. - Finalize
Fields - A trait that lets you finalize all fields of a piece of data
- Scan
- A trait capturing the ability of data to be scanned for references to data in a
Gc. - ToScan
- A trait that allows something that is
Scanto be converted to adynref.
Functions§
- collect
- A function for manually running a collection, ignoring the heuristic that governs normal garbage collector operations.
- number_
of_ active_ handles - Returns how many
Gcs are currently in use. - number_
of_ tracked_ allocations - Returns how many underlying allocations are currently allocated.
- run_
with_ gc_ cleanup - A convenience method for helping ensure your destructors are run.
- set_
gc_ trigger_ percent - Sets the percent more data that’ll trigger collection.
- synchronize_
destructors - Block the current thread until the background thread has finished running the destructors for all data that was marked as garbage at the point this method was called.
Type Aliases§
- GMutex
- A convenient alias for
Gc<Mutex<T>>. Note thatGc<Mutex<T>>has additional specialized methods for working withMutexs insideGcs. - GRef
Cell - A convenient alias for
Gc<RefCell<T>>. Note thatGc<RefCell<T>>has additional specialized methods for working withRefCells insideGcs. - GRwLock
- A convenient alias for
Gc<RwLock<T>>. Note thatGc<Mutex<T>>has additional specialized methods for working withMutexs insideGcs.
Derive Macros§
- Finalize
- The
Finalizederive, powering#[derive(Finalize)] - Finalize
Fields - The
FinalizeFieldsderive, powering#[derive(FinalizeFields)] - Scan
- The
Scanderive, powering#[derive(Scan)]. Important details here!