Expand description
ResourceLink — ref-counted shared-memory handles with TTL / orphan GC
DCC applications (Maya, Houdini, Blender, 3dsMax, Unreal, …) share large
payloads (meshes, textures, render frames) via shared memory and can crash
at any time, leaving orphaned segments on the OS. ResourceLink wraps a
SharedMemory region and adds:
- In-segment reference counting (CAS-updated
AtomicU32in the first cache-line) so consumers know when the last holder is gone. - TTL — every segment stores its creation timestamp; segments older than the configured TTL are treated as orphans.
- Explicit GC via
ResourceLink::gc_orphansthat can be run on startup and in idle-callback loops.
§Example
use ipckit::{ResourceLink, ResourceKind};
use std::time::Duration;
// Producer (creates + acquires)
let link = ResourceLink::create("frame-0001", 1024 * 1024,
ResourceKind::SharedMemory,
Some(Duration::from_secs(30)))?;
// … write payload …
// link is released on Drop (refcount → 0 → unlink)
// Consumer (opens + acquires)
let consumer_link = ResourceLink::acquire("frame-0001")?;
// … read payload …
drop(consumer_link); // refcount−1
// Maintenance sweep at startup / idle:
let removed = ResourceLink::gc_orphans(Duration::from_secs(60));
println!("Removed {} stale segments", removed);Structs§
- Resource
Link - A ref-counted handle to a shared-memory segment.
- Resource
Link Info - Metadata snapshot for a
ResourceLink.
Enums§
- Resource
Kind - The kind of resource backing a
ResourceLink.