Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › Io/ › Threaded.zig › tryLockStderr
tryLockStderr
Threaded.tryLockStderr
fn tryLockStderr (userdata : ?*anyopaque , terminal_mode : ?Io .Terminal .Mode ) Io .Cancelable !?Io .LockedStderr
File
Code
fn tryLockStderr (userdata : ?*anyopaque , terminal_mode : ?Io .Terminal .Mode ) Io .Cancelable !?Io .LockedStderr {
const t : *Threaded = @ptrCast (@alignCast (userdata ));
const current_thread_id = Thread .currentId ();
if (@atomicLoad (std .Thread .Id , &t .stderr_mutex_locker , .unordered ) != current_thread_id ) {
if (!t .stderr_mutex .tryLock ()) return null ;
assert (t .stderr_mutex_lock_count == 0 );
@atomicStore (std .Thread .Id , &t .stderr_mutex_locker , current_thread_id , .unordered );
}
t .stderr_mutex_lock_count += 1 ;
return try initLockedStderr (t , terminal_mode );
}