aboutsummaryrefslogtreecommitdiff
path: root/api/channels.md
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-18 20:00:21 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-18 20:00:21 -0400
commitc338c3f08c6a13242e975dd344bad63a3cec9eee (patch)
tree4e68f126de0bd900ff0556d71cb3a8ed980d3ac9 /api/channels.md
parentc972b8ba5bd61860e294322336bc9a6e0b3b6d07 (diff)
Update docs
Diffstat (limited to 'api/channels.md')
-rw-r--r--api/channels.md9
1 files changed, 9 insertions, 0 deletions
diff --git a/api/channels.md b/api/channels.md
index 880825ce..4b8d416a 100644
--- a/api/channels.md
+++ b/api/channels.md
@@ -3,6 +3,13 @@
Channels are a thread-safe message queue for communicating between threads,
although they can also be used as a general-purpose queue.
+## Syntax
+
+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
+the channel if the maximum size is reached.
+
```tomo
channel := |Int|
channel:push(10)
@@ -11,6 +18,8 @@ channel:push(20)
= 10
>> channel:pop()
= 20
+
+small_channel := |Int; max_size=5|
```
## Channel Methods