
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Arc
/
Weak
: drop-in replacements for the standard library's Arc
and Weak
, but implemented with deferred reclamation semantics.AtomicArc
/
AtomicWeak
: variants of Arc
and
Weak
with atomically updatable pointers, supporting standard atomic operations like load
and compare_exchange
.Guard
: A novel smart pointer that can be loaded from
AtomicArc
or AtomicWeak
, designed to reduce contention when multiple threads operate on the same atomic variable.
It prevents deallocation but does not contribute to reference counts. (This was renamed from Snapshot
in an earlier
version, to reduce confusion.)Data structures built with Arc
typically require locks for synchronization, as only
the reference counts may be atomically updated, not the pointer nor the contained data. While locks
are often the right approach, lock-free data structures can have better theoretical and practical
performance guarantees in highly-contended settings.
Instead of protecting in-place updates with locks, an alternative approach is to perform copy-on-write updates by
atomically installing pointers. To avoid use-afer-free, mechanisms for safe memory reclamation (SMR) are typically
utilized (i.e. hazard pointers, epoch-based reclamation). aarc
uses the blazingly fast algorithm provided by the
fast-smr
crate and builds on top of it, hiding unsafety and providing
convenient RAII semantics through reference-counted pointers.
Example 1: Treiber Stack
use std::ptr::null;
use aarc::{Arc, AsPtr, AtomicArc, Guard};
struct StackNode {
val: usize,
next: Option<Arc<Self>>,
}
struct Stack {
top: AtomicArc<StackNode>,
}
impl Stack {
fn push(&self, val: usize) {
let mut top = self.top.load();
loop {
let top_ptr = top.as_ref().map_or(null(), AsPtr::as_ptr);
let new_node = Arc::new(StackNode {
val,
next: top.as_ref().map(Arc::from),
});
match self.top.compare_exchange(top_ptr, Some(&new_node)) {
Ok(()) => break,
Err(before) => top = before,
}
}
}
fn pop(&self) -> Option<Guard<StackNode>> {
let mut top = self.top.load();
while let Some(top_node) = top.as_ref() {
match self
.top
.compare_exchange(top_node.as_ptr(), top_node.next.as_ref())
{
Ok(()) => return top,
Err(actual_top) => top = actual_top,
}
}
None
}
}
FAQs
Unknown package
We found that aarc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.