From 8363d53bd27c621cb342fea15736a3b11231f2a4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 18 Aug 2024 23:59:13 -0400 Subject: Update channel API to take a Where parameter --- api/channels.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'api') 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. -- cgit v1.2.3