Function tryLockShared [src]

Attempts to obtain shared lock ownership. Returns true if the lock is obtained, false otherwise.

Prototype

pub fn tryLockShared(rwl: *SingleThreadedRwLock) bool

Parameters

rwl: *SingleThreadedRwLock

Source

pub fn tryLockShared(rwl: *SingleThreadedRwLock) bool { switch (rwl.state) { .unlocked => { rwl.state = .locked_shared; assert(rwl.shared_count == 0); rwl.shared_count = 1; return true; }, .locked_shared => { rwl.shared_count += 1; return true; }, .locked_exclusive => return false, } }