arc
Arc<T>, the thread-safe counterpart to rc<T>.
(let [a (arc-new 42)
b (arc-clone a)]
(println (arc-get b)) ; => 42
(println (arc-strong-count a)) ; => 2
(arc-drop b)
(arc-drop a))
Since: 2026-08-20
arc-new
(arc-new [v : int] :)
allocate an Arc holding an int payload, strong count 1.
| v | the value to share |
A new Arc with strong count 1 and the weak sentinel held.
(arc-get (arc-new 42)) ; => 42
Since: 2026-08-20
arc-clone
(arc-clone [^borrow a : Arc] :)
add a strong reference.
| a | the Arc to clone (borrowed; the caller keeps its own handle) |
A second Arc onto the same value. Both must be dropped.
(let [a (arc-new 1) b (arc-clone a)]
(println (arc-strong-count a))) ; => 2
Since: 2026-08-20
arc-get
(arc-get [^borrow a : Arc] :)
read the shared value.
| a | the Arc to read (borrowed) |
The contained value; 0 for a null handle or one already dropped.
(arc-get (arc-new 7)) ; => 7
Since: 2026-08-20
arc-strong-count
(arc-strong-count [^borrow a : Arc] :)
how many Arc handles share this value.
| a | the Arc to inspect (borrowed) |
The current strong count; 0 for a null handle.
(arc-strong-count (arc-new 1)) ; => 1
Since: 2026-08-20
arc-weak-count
(arc-weak-count [^borrow a : Arc] :)
how many ArcWeak handles point at this value.
| a | the Arc to inspect (borrowed) |
The weak count excluding the sentinel; 0 for a null handle.
(let [a (arc-new 1) w (arc-downgrade a)]
(println (arc-weak-count a))) ; => 1
Since: 2026-08-20
arc-drop
(arc-drop [a : Arc] :)
release one strong reference.
| a | the Arc to release (consumed -- do not use it afterwards) |
(let [a (arc-new 1)] (arc-drop a))
Since: 2026-08-20
arc-downgrade
(arc-downgrade [^borrow a : Arc] :)
make a non-owning ArcWeak from an Arc.
| a | the Arc to downgrade (borrowed) |
An ArcWeak onto the same control block. Release it with arc-weak-drop.
(let [a (arc-new 1) w (arc-downgrade a)]
(arc-weak-drop w) (arc-drop a))
Since: 2026-08-20
arc-upgrade
(arc-upgrade [^borrow w : ArcWeak] :)
arc-weak-drop
(arc-weak-drop [w : ArcWeak] :)
release one weak reference.
| w | the ArcWeak to release (consumed -- do not use it afterwards) |
(let [a (arc-new 1) w (arc-downgrade a)]
(arc-weak-drop w) (arc-drop a))
Since: 2026-08-20
Internal definitions
arc/autolink-hint-- link libturi and hoist the ArcControlBlock decls.ArcArcWeakarc-try-upgrade-- try to get a strong Arc back from a weak handle.arc-weak->arc-- internal: view a weak handle as the strong one it