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

put

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

Appends elements to the end of the queue, potentially blocking if there is insufficient capacity. Returns when any one of the following conditions is satisfied:

  • At least min elements have been added to the queue
  • The queue is closed
  • The current task is canceled

Returns how many of elements have been added to the queue, if any. If an error is returned, no elements have been added.

If the queue is closed or the task is canceled, but some items were already added before the closure or cancelation, then put 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 queue as many of elements as is possible without blocking.

Asserts that elements.len >= min.

Params

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

File

Io.zig:2417
2417
2418
2419
        pub fn put(q: *@This(), io: Io, elements: []const Elem, min: usize) (QueueClosedError || Cancelable)!usize {
            return @divExact(try q.type_erased.put(io, @ptrCast(elements), min * @sizeOf(Elem)), @sizeOf(Elem));
        }