Stdlib module threading/mutex.vitl
This page is a wiki-style reference for one concrete stdlib file. It explains what the file owns, where it fits in the family, and how to decide whether this is the right surface to depend on.
threading/mutex.vitl.Family: threading
Kind: public stdlib surface
Page style: this reference follows the same “encyclopedic card + portrait + usage contract” logic as the keyword pages, but for stdlib modules.
Summary
Overview
| Field | Value |
|---|---|
| Path | threading/mutex.vitl |
| Family | threading |
| Kind | public stdlib surface |
| Line count | 351 |
| Declared procedures | 30 |
| Declared forms/picks | 4 |
`threading/mutex.vitl` is a public stdlib surface inside the `threading` family. It should be read as one focused slice of the broader family responsibility: Thread, mutex, and pool-based concurrency helpers.
Purpose
This file should be chosen because of responsibility, not because its name “sounds close enough”. Inside the threading family, it carries one focused part of the contract and keeps that responsibility separate from neighboring concerns.
- A worker pool can process tasks in parallel while leaving task definition and result aggregation elsewhere.
Top-level API inventory
| Surface | Items |
|---|---|
| Procedures | mutex_new, mutex_recursive_new, mutex_lock, mutex_try_lock, mutex_lock_timeout, mutex_unlock, mutex_get, mutex_set, with_lock, rwlock_new, rwlock_read_lock, rwlock_read_unlock |
| Forms | Mutex, RwLock, Condition, Semaphore |
| Picks | none declared at top level |
| Constants | MUTEX_ID_COUNTER, RWLOCK_ID_COUNTER, CONDITION_ID_COUNTER, SEMAPHORE_ID_COUNTER |
Imported surfaces
vitte/stdlib/threading/thread // Mutex
How to use this module
Start by reading the file as an ownership boundary. Ask three questions: what enters this module, what stable types or procedures it exports, and what adjacent module should stay outside of it.
- Open the family page first to understand why this area of the stdlib exists.
- Read the source excerpt below to see the namespace, imports, and first declared surfaces.
- Check the neighbor list to avoid coupling this module with an adjacent responsibility by habit.
Source shape
space vitte/stdlib/threading/mutex
use vitte/stdlib/threading/thread
// Mutex - Mutual Exclusion Lock
form Mutex<T> {
id: int,
data: T,
locked: bool,
owner_thread: int,
lock_count: int, // For recursive mutex
waiters: [int], // Waiting thread IDs
The excerpt is not meant to replace the file. It exists to make the module recognizable at first glance, the same way a Wikipedia infobox helps the reader orient before reading the whole article.
Integration boundaries
Within threading, this file should remain focused. If a future helper changes the host boundary, scheduling boundary, or data-shape boundary, it probably belongs in a neighbor module instead of being added here by convenience.
- Family responsibility: Thread, mutex, and pool-based concurrency helpers.
- Family architecture role: Use `threading` when the program needs explicit concurrency coordination rather than single-threaded transformation.