aboutsummaryrefslogtreecommitdiff
path: root/api/channels.md
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-18 23:59:13 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-18 23:59:13 -0400
commit8363d53bd27c621cb342fea15736a3b11231f2a4 (patch)
tree094530cdd947f57197171f1dda58057739d63151 /api/channels.md
parent9e07c6adc7a0616eec40e78024a8501ec7d96559 (diff)
Update channel API to take a Where parameter
Diffstat (limited to 'api/channels.md')
-rw-r--r--api/channels.md16
1 files changed, 12 insertions, 4 deletions
diff --git a/api/channels.md b/api/channels.md
index ca7ce17e..88cb46ff 100644
--- a/api/channels.md
+++ b/api/channels.md
@@ -31,13 +31,15 @@ Adds an item to the channel.
**Usage:**
```markdown
-give(channel:|T|, item: T) -> Void
+give(channel:|T|, item: T, where: Where = Where.End) -> Void
```
**Parameters:**
- `channel`: The channel to which the item will be added.
- `item`: The item to add to the channel.
+- `where`: Where to put the item (at the `Start` or `End` of the queue).
+ `Anywhere` defaults to `End`.
**Returns:**
Nothing.
@@ -56,13 +58,15 @@ Adds multiple items to the channel.
**Usage:**
```markdown
-give_all(channel:|T|, items: [T]) -> Void
+give_all(channel:|T|, items: [T], where: Where = Where.End) -> Void
```
**Parameters:**
- `channel`: The channel to which the items will be added.
- `items`: The array of items to add to the channel.
+- `where`: Where to put the items (at the `Start` or `End` of the queue).
+ `Anywhere` defaults to `End`.
**Returns:**
Nothing.
@@ -81,12 +85,14 @@ Removes and returns an item from the channel. If the channel is empty, it waits
**Usage:**
```markdown
-get(channel:|T|) -> T
+get(channel:|T|, where: Where = Where.Start) -> T
```
**Parameters:**
- `channel`: The channel from which to remove an item.
+- `where`: Where to get the item from (from the `Start` or `End` of the queue).
+ `Anywhere` defaults to `Start`.
**Returns:**
The item removed from the channel.
@@ -107,12 +113,14 @@ it. If the channel is empty, it waits until an item is available.
**Usage:**
```markdown
-peek(channel:|T|) -> T
+peek(channel:|T|, where: Where = Where.Start) -> T
```
**Parameters:**
- `channel`: The channel from which to remove an item.
+- `where`: Which end of the channel to peek from (the `Start` or `End`).
+ `Anywhere` defaults to `Start`.
**Returns:**
The item removed from the channel.