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 standard library. Public Function
pubfntryLock(rl: *RwLock, io: Io) bool {
if (rl.mutex.tryLock()) {
// Unlike `lock`, this never registers in `writer_mask`, so holding the mutex does// not stop a reader from taking the fast path; the CAS catches one that raced in// after `state` was loaded.conststate = @atomicLoad(usize, &rl.state, .seq_cst);
if (state & reader_mask == 0) {
_ = @cmpxchgStrong(
usize,
&rl.state,
state,
state | is_writing,
.seq_cst,
.seq_cst,
) orelsereturntrue;
}
rl.mutex.unlock(io);
}
returnfalse;
}