diff options
Diffstat (limited to 'docs/threads.md')
| -rw-r--r-- | docs/threads.md | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/docs/threads.md b/docs/threads.md deleted file mode 100644 index 3bd2dd0f..00000000 --- a/docs/threads.md +++ /dev/null @@ -1,93 +0,0 @@ -# Threads - -Tomo supports POSIX threads (pthreads) through the `Thread` type. The -recommended practice is to have each thread interact with other threads only -through [mutex-guarded datastructures](mutexed.md). - -## Thread Methods - -- [`func cancel(thread: Thread)`](#cancel) -- [`func detach(thread: Thread)`](#detach) -- [`func join(thread: Thread)`](#join) -- [`func new(fn: func(->Void) -> Thread)`](#new) - -### `cancel` -Requests the cancellation of a specified thread. - -```tomo -func cancel(thread: Thread) -``` - -- `thread`: The thread to cancel. - -**Returns:** -Nothing. - -**Example:** -```tomo ->> thread:cancel() -``` - ---- - -### `detach` -Detaches a specified thread, allowing it to run independently. - -```tomo -func detach(thread: Thread) -``` - -- `thread`: The thread to detach. - -**Returns:** -Nothing. - -**Example:** -```tomo ->> thread:detach() -``` -### `join` -Waits for a specified thread to terminate. - -```tomo -func join(thread: Thread) -``` - -- `thread`: The thread to join. - -**Returns:** -Nothing. - -**Example:** -```tomo ->> thread:join() -``` - ---- - -### `new` -Creates a new thread to execute a specified function. - -```tomo -func new(fn: func(->Void) -> Thread) -``` - -- `fn`: The function to be executed by the new thread. - -**Returns:** -A new `Thread` object representing the created thread. - -**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 -``` |
