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 standard library.
std › Io › Uring › Group › lock Private Function lock Doc Source Private Function std.Io.Uring.Group.lock
fn lock (group : Group , ev : *Evented ) void Params File Io/Uring.zig: 1572
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605 fn lock (group : Group , ev : *Evented ) void {
const mutex = group .mutexPtr ();
{
const old_state = @atomicRmw (
Mutex ,
mutex ,
.Or ,
.{ .locked = true , .contended = false , .shared2 = 0 },
.acquire ,
);
if (!old_state .locked ) {
@branchHint (.likely );
return ;
}
if (old_state .contended ) {
futexWaitUncancelable (ev , @ptrCast (mutex ), @bitCast (old_state ));
}
}
while (true ) {
var old_state = @atomicRmw (
Mutex ,
mutex ,
.Or ,
.{ .locked = true , .contended = true , .shared2 = 0 },
.acquire ,
);
if (!old_state .locked ) {
@branchHint (.likely );
return ;
}
old_state .contended = true ;
futexWaitUncancelable (ev , @ptrCast (mutex ), @bitCast (old_state ));
}
}