# std.Io.Queue: introduce closure and fix a bug · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/67eed9955005aaa02344b8d566ba140b9f2e0e18)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 67eed9955005aaa02344b8d566ba140b9f2e0e18

Requested commit: 67eed9955005aaa02344b8d566ba140b9f2e0e18

Commit: 67eed9955005aaa02344b8d566ba140b9f2e0e18

Tree: 1f11358b2a1fd708738a93df52ff18175a7e2c7c

Author: Matthew Lugg

Committer: Matthew Lugg

## Message

```
std.Io.Queue: introduce closure and fix a bug

Queues can now be "closed". A closed queue cannot have more elements
appended with `put`, and blocked calls to `put` will immediately unblock
having failed to append some elements. Calls to `get` will continue to
succeed as long as the queue buffer is non-empty, but will then never
block; already-blocked calls to `get` will unblock.

All queue get/put operations can now return `error.Closed` to indicate
that the queue has been closed. For bulk get/put operations, they may
add/receive fewer elements than the minimum requested *if* the queue was
closed or the calling task was canceled. In that case, if any elements
were already added/received, they are returned first, and successive
calls will return `error.Closed` or `error.Canceled`.

Also, fix a bug where `Queue.get` could deadlock because it incorrectly
blocked until the given buffer was *filled*.

Resolves: #30141

```

## Parents

- [fa7e818e144f2fd316fc54492f4699f6e1524738](https://git.cafe/gitcafe/zig/commit/fa7e818e144f2fd316fc54492f4699f6e1524738?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/67eed9955005aaa02344b8d566ba140b9f2e0e18?format=markdown)
