summaryrefslogtreecommitdiff
path: root/docs/std/thread.md
diff options
context:
space:
mode:
authorZuhaitz <zuhaitz.zechhub@gmail.com>2026-01-31 17:22:17 +0000
committerGitHub <noreply@github.com>2026-01-31 17:22:17 +0000
commit962d659c61212b1a23acfe56dda7cb92b721feda (patch)
treeba1637d3885213095b312f81a477c33b1ebca6aa /docs/std/thread.md
parente521ee7d175393ef37579ebd61ccb7e8d56a397f (diff)
parent91ed9fdd65e09bd6cd32e44dd07c390f2cf79c22 (diff)
Merge branch 'main' into main
Diffstat (limited to 'docs/std/thread.md')
-rw-r--r--docs/std/thread.md47
1 files changed, 47 insertions, 0 deletions
diff --git a/docs/std/thread.md b/docs/std/thread.md
new file mode 100644
index 0000000..6ac7e29
--- /dev/null
+++ b/docs/std/thread.md
@@ -0,0 +1,47 @@
+# Concurrency (`std/thread.zc`)
+
+The `std/thread` module provides primitives for multithreading and synchronization.
+
+## Usage
+
+```zc
+import "std/thread.zc"
+```
+
+## Functions
+
+- **`fn sleep_ms(ms: int)`**
+ Sleeps the current thread for the specified number of milliseconds.
+
+## Types
+
+### Type `Thread`
+
+Represents a handle to a spawned thread.
+
+#### Methods
+
+- **`fn spawn(func: fn()) -> Result<Thread>`**
+ Spawns a new thread executing the provided function.
+ > Note: Currently supports void functions with no arguments.
+
+- **`fn join(self) -> Result<bool>`**
+ Blocks the current thread until the spawned thread finishes.
+
+### Type `Mutex`
+
+A mutual exclusion primitive for protecting shared data.
+
+#### Methods
+
+- **`fn new() -> Mutex`**
+ Creates a new mutex.
+
+- **`fn lock(self)`**
+ Acquires the lock. Blocks if the lock is already held.
+
+- **`fn unlock(self)`**
+ Releases the lock.
+
+- **`fn free(self)`**
+ Destroys the mutex and frees associated resources.