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 › os › linux › IoUring › BufferGroup › init Public Function init Doc Source Public Function std.os.linux.IoUring.BufferGroup.init
pub fn init (
ring : *IoUring ,
allocator : Allocator ,
group_id : u16 ,
buffer_size : u32 ,
buffers_count : u16 ,
) !BufferGroup Params ring : *IoUring allocator : Allocator group_id : u16 buffer_size : u32 buffers_count : u16 File os/linux/IoUring.zig: 1644
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678 pub fn init (
ring : *IoUring ,
allocator : Allocator ,
group_id : u16 ,
buffer_size : u32 ,
buffers_count : u16 ,
) !BufferGroup {
const buffers = try allocator .alloc (u8 , buffer_size * buffers_count );
errdefer allocator .free (buffers );
const heads = try allocator .alloc (u32 , buffers_count );
errdefer allocator .free (heads );
const br = try setup_buf_ring (ring .fd , buffers_count , group_id , .{ .inc = true });
buf_ring_init (br );
const mask = buf_ring_mask (buffers_count );
var i : u16 = 0 ;
while (i < buffers_count ) : (i += 1 ) {
const pos = buffer_size * i ;
const buf = buffers [pos .. pos + buffer_size ];
heads [i ] = 0 ;
buf_ring_add (br , buf , i , mask , i );
}
buf_ring_advance (br , buffers_count );
return BufferGroup {
.ring = ring ,
.group_id = group_id ,
.br = br ,
.buffers = buffers ,
.heads = heads ,
.buffer_size = buffer_size ,
.buffers_count = buffers_count ,
};
}