diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-05 00:21:30 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-05 00:21:30 -0500 |
| commit | 0a3ad8ba914ab42ebbb88a3d955f71d71d581fc1 (patch) | |
| tree | e984b58347627f0417a6961dbb8e83afe4739653 /docs/threads.md | |
| parent | 665050940f1562b045efe942686d04b3c3fac381 (diff) | |
Alphabetize and index functions
Diffstat (limited to 'docs/threads.md')
| -rw-r--r-- | docs/threads.md | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/docs/threads.md b/docs/threads.md index 4d91e8bd..1ccacc38 100644 --- a/docs/threads.md +++ b/docs/threads.md @@ -6,64 +6,56 @@ through [mutex-guarded datastructures](mutexed.md). ## Thread Methods -### `new` +- [`func cancel(thread: Thread)`](#`cancel) +- [`func detach(thread: Thread)`](#`detach) +- [`func join(thread: Thread)`](#`join) +- [`func new(fn: func(->Void) -> Thread)`](#`new) + +### `cancel` **Description:** -Creates a new thread to execute a specified function. +Requests the cancellation of a specified thread. **Signature:** ```tomo -func new(fn: func(->Void) -> Thread) +func cancel(thread: Thread) ``` **Parameters:** -- `fn`: The function to be executed by the new thread. +- `thread`: The thread to cancel. **Returns:** -A new `Thread` object representing the created thread. +Nothing. **Example:** ```tomo ->> jobs := |Int| ->> results := |Int| ->> thread := Thread.new(func(): - repeat: - input := jobs:get() - results:give(input + 10 -) -= Thread<0x12345678> ->> jobs:give(10) ->> results:get() -= 11 +>> thread:cancel() ``` --- -### `cancel` +### `detach` **Description:** -Requests the cancellation of a specified thread. +Detaches a specified thread, allowing it to run independently. **Signature:** ```tomo -func cancel(thread: Thread) +func detach(thread: Thread) ``` **Parameters:** -- `thread`: The thread to cancel. +- `thread`: The thread to detach. **Returns:** Nothing. **Example:** ```tomo ->> thread:cancel() +>> thread:detach() ``` - ---- - ### `join` **Description:** @@ -88,24 +80,34 @@ Nothing. --- -### `detach` +### `new` **Description:** -Detaches a specified thread, allowing it to run independently. +Creates a new thread to execute a specified function. **Signature:** ```tomo -func detach(thread: Thread) +func new(fn: func(->Void) -> Thread) ``` **Parameters:** -- `thread`: The thread to detach. +- `fn`: The function to be executed by the new thread. **Returns:** -Nothing. +A new `Thread` object representing the created thread. **Example:** ```tomo ->> thread:detach() +>> jobs := |Int| +>> results := |Int| +>> thread := Thread.new(func(): + repeat: + input := jobs:get() + results:give(input + 10 +) += Thread<0x12345678> +>> jobs:give(10) +>> results:get() += 11 ``` |
