Skip to main content

Module resource_link

Module resource_link 

Source
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 AtomicU32 in 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_orphans that 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§

ResourceLink
A ref-counted handle to a shared-memory segment.
ResourceLinkInfo
Metadata snapshot for a ResourceLink.

Enums§

ResourceKind
The kind of resource backing a ResourceLink.