Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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

get

Public Function
std.Io.Queue.get
pub fn get(q: *@This(), io: Io, buffer: []Elem, min: usize) (QueueClosedError || Cancelable)!usize

Receives elements from the beginning of the queue, potentially blocking if there are insufficient elements currently in the queue. Returns when any one of the following conditions is satisfied:

  • At least min elements have been received from the queue
  • The queue is closed and contains no buffered elements
  • The current task is canceled

Returns how many elements of buffer have been populated, if any. If an error is returned, no elements have been populated.

If the queue is closed or the task is canceled, but some items were already received before the closure or cancelation, then get may return a number lower than min, in which case future calls are guaranteed to return error.Canceled or error.Closed.

A return value of 0 is only possible if min is 0, in which case the call is guaranteed to fill as much of buffer as is possible without blocking.

Asserts that buffer.len >= min.

Params

  • q: *@This()
  • io: Io
  • buffer: []Elem
  • min: usize

File

Io.zig:2474
2474
2475
2476
        pub fn get(q: *@This(), io: Io, buffer: []Elem, min: usize) (QueueClosedError || Cancelable)!usize {
            return @divExact(try q.type_erased.get(io, @ptrCast(buffer), min * @sizeOf(Elem)), @sizeOf(Elem));
        }