From 1f16d63ac783d9b1bb1d4a65676476d14f0af713 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 18 Aug 2024 23:25:35 -0400 Subject: [PATCH] Update API for give/get --- api/channels.md | 28 ++++++++++++++-------------- api/threads.md | 8 ++++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/api/channels.md b/api/channels.md index 48116dc..dbb6707 100644 --- a/api/channels.md +++ b/api/channels.md @@ -7,16 +7,16 @@ although they can also be used as a general-purpose queue. The syntax to create a channel is `|:T|`, where `T` is the type that will be passed through the channel. You can also specify a maximum size for the -channel, which will cause pushing to block until the recipient has popped from +channel, which will cause giving to block until the recipient has gotten from the channel if the maximum size is reached. ```tomo channel := |:Int| -channel:push(10) -channel:push(20) ->> channel:pop() +channel:give(10) +channel:give(20) +>> channel:get() = 10 ->> channel:pop() +>> channel:get() = 20 small_channel := |:Int; max_size=5| @@ -24,14 +24,14 @@ small_channel := |:Int; max_size=5| ## Channel Methods -### `push` +### `give` **Description:** Adds an item to the channel. **Usage:** ```markdown -push(channel:|T|, item: T) -> Void +give(channel:|T|, item: T) -> Void ``` **Parameters:** @@ -44,19 +44,19 @@ Nothing. **Example:** ```markdown ->> channel:push("Hello") +>> channel:give("Hello") ``` --- -### `push_all` +### `give_all` **Description:** Adds multiple items to the channel. **Usage:** ```markdown -push_all(channel:|T|, items: [T]) -> Void +give_all(channel:|T|, items: [T]) -> Void ``` **Parameters:** @@ -69,19 +69,19 @@ Nothing. **Example:** ```markdown ->> channel:push_all([1, 2, 3]) +>> channel:give_all([1, 2, 3]) ``` --- -### `pop` +### `get` **Description:** Removes and returns an item from the channel. If the channel is empty, it waits until an item is available. **Usage:** ```markdown -pop(channel:|T|) -> T +get(channel:|T|) -> T ``` **Parameters:** @@ -93,7 +93,7 @@ The item removed from the channel. **Example:** ```markdown ->> channel:pop() +>> channel:get() = "Hello" ``` diff --git a/api/threads.md b/api/threads.md index b6ae513..228fc8a 100644 --- a/api/threads.md +++ b/api/threads.md @@ -29,12 +29,12 @@ A new `Thread` object representing the created thread. >> results := |Int| >> thread := Thread.new(func(): while yes: - input := jobs:pop() - results:push(input + 10 + input := jobs:get() + results:give(input + 10 ) = Thread<0x12345678> ->> jobs:push(10) ->> results:pop() +>> jobs:give(10) +>> results:get() = 11 ```