Function tryLock [src]

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

Prototype

pub fn tryLock(rwl: *SingleThreadedRwLock) bool

Parameters

rwl: *SingleThreadedRwLock

Source

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