Skip to main content

Module lock

Module lock 

Source
Expand description

Lock helpers shared by lanes and backends.

Replace .lock().unwrap() and .read()/.write().unwrap() in hot paths with mutex_lock / read_lock / write_lock so a poisoned lock yields a LaneError::LockPoisoned (or a RenderError) instead of crashing the frame.

These helpers live in khora-core so both khora-lanes and khora-infra can use them without crossing crate boundaries.

Functionsยง

mutex_lock
Locks a Mutex<T>, mapping poisoning to LaneError::LockPoisoned.
mutex_lock_render
Locks a Mutex<T>, mapping poisoning to a RenderError.
read_lock
Acquires a read lock, mapping poisoning to LaneError::LockPoisoned.
read_lock_render
Like mutex_lock_render but for RwLock<T> read access.
write_lock
Acquires a write lock, mapping poisoning to LaneError::LockPoisoned.
write_lock_render
Like mutex_lock_render but for RwLock<T> write access.