unlock
Releases the Mutex which was previously acquired with lock or tryLock.
It is undefined behavior to unlock from a different thread that it was locked from.
Function parameters
Parameters
- r:*Recursive
Acquires the `Mutex` without blocking the caller's thread.
Functions
= .{ .mutex = .{}, .thread_id = invalid_thread_id, .lock_count = 0, }
Values
- init
- = .{ .mutex = .{}, .thread_id = invalid_thread_id, .lock_count = 0, }
Source
Implementation
pub fn unlock(r: *Recursive) void {
r.lock_count -= 1;
if (r.lock_count == 0) {
@atomicStore(std.Thread.Id, &r.thread_id, invalid_thread_id, .unordered);
r.mutex.unlock();
}
}