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 › Fiber › CancelStatus Private Struct CancelStatus Doc Source Private Struct std.Io.Uring.Fiber.CancelStatus
const CancelStatus = packed struct (u32 ) Fields Types Values Functions File Io/Uring.zig: 167
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211 const CancelStatus = packed struct (u32 ) {
requested : bool ,
awaiting : Awaiting ,
const unrequested : CancelStatus = .{ .requested = false , .awaiting = .nothing };
const Awaiting = enum (u31 ) {
nothing = std .math .maxInt (u31 ),
group = std .math .maxInt (u31 ) - 1 ,
/// An io_uring fd.
_ ,
fn subWrap (lhs : Awaiting , rhs : Awaiting ) Awaiting {
return @fromBackingInt (@intCast (@backingInt (lhs ) -% @backingInt (rhs )));
}
fn fromIoUringFd (fd : fd_t ) Awaiting {
const awaiting : Awaiting = @fromBackingInt (@intCast (fd ));
switch (awaiting ) {
.nothing , .group => unreachable ,
_ => return awaiting ,
}
}
fn toIoUringFd (awaiting : Awaiting ) fd_t {
switch (awaiting ) {
.nothing , .group => unreachable ,
_ => return @backingInt (awaiting ),
}
}
};
fn changeAwaiting (
cancel_status : *CancelStatus ,
old_awaiting : Awaiting ,
new_awaiting : Awaiting ,
) bool {
const old_cancel_status = @atomicRmw (CancelStatus , cancel_status , .Add , .{
.requested = false ,
.awaiting = new_awaiting .subWrap (old_awaiting ),
}, .monotonic );
assert (old_cancel_status .awaiting == old_awaiting );
return old_cancel_status .requested ;
}
}