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 › findReadyFiber Private Function findReadyFiber Doc Source Private Function std.Io.Uring.findReadyFiber
fn findReadyFiber (ev : *Evented , thread : *Thread ) ?*Fiber Params File Io/Uring.zig: 927
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959 fn findReadyFiber (ev : *Evented , thread : *Thread ) ?*Fiber {
if (@atomicRmw (?*Fiber , &thread .ready_queue , .Xchg , Fiber .finished , .acquire )) |ready_fiber | {
assert (ready_fiber != Fiber .finished );
@atomicStore (?*Fiber , &thread .ready_queue , ready_fiber .status .queue_next , .release );
ready_fiber .status .queue_next = null ;
return ready_fiber ;
}
const active_threads = @atomicLoad (u32 , &ev .threads .active , .acquire );
for (0 ..@min (max_steal_ready_search , active_threads )) |_ | {
defer thread .steal_ready_search_index += 1 ;
if (thread .steal_ready_search_index == active_threads ) thread .steal_ready_search_index = 0 ;
const steal_ready_search_thread =
&ev .threads .allocated [0 ..active_threads ][thread .steal_ready_search_index ];
if (steal_ready_search_thread == thread ) continue ;
const ready_fiber =
@atomicLoad (?*Fiber , &steal_ready_search_thread .ready_queue , .monotonic ) orelse continue ;
if (ready_fiber == Fiber .finished ) continue ;
if (@cmpxchgWeak (
?*Fiber ,
&steal_ready_search_thread .ready_queue ,
ready_fiber ,
null ,
.acquire ,
.monotonic ,
)) |_ | continue ;
@atomicStore (?*Fiber , &thread .ready_queue , ready_fiber .status .queue_next , .release );
ready_fiber .status .queue_next = null ;
return ready_fiber ;
}
// couldn't find anything to do, so we are now open for business
@atomicStore (?*Fiber , &thread .ready_queue , null , .monotonic );
return null ;
}