Thread<ToolKit> Classes


Like processes, a thread can access most of its own attributes, but can access only a small subset of the attributes for another thread. Therefore, thread objects are modeled using two classes: os_this_thread , which represents the current thread, and os_thread , which represents other threads.

Following is a list and brief description of the thread and synchronization classes.

Threads and Thread-Specific Data

os_thread represents a single thread of control.
os_this_thread represents the current thread.
os_future_thread represents a user supplied function that executes asynchronously in a different thread.
os_future represents the future result of a user supplied function.
os_trap represents a way to allow the user to add many os_futures and then wait for each in order to return with its redeemed value.
os_thread_pool represents a pool of threads used repeatedly to run small tasks.

Semaphores

os_critical_section simple, highly-efficient synchronization object that locks and unlocks a block of code that is considered a critical section.
os_mutex the most common synchronization mechanism; locks and unlocks a single shared resource. When locked multiple times by the same thread, a mutex must be unlocked the same number of times. Also called a recursive mutex.
os_fifo_mutex similar to os_mutex, but guarantees order of resource obtainment based on first-in, first-out (FIFO) scheduling mechanism.
os_priority_mutex similar to os_mutex, but guarantees order of resource obtainment based on developer-driven priority mechanism.
os_simple_mutex permits multiple locks by the same thread, but a single-release of resource.
os_simple_fifo_mutex similar to os_simple_mutex, but guarantees order of resource obtainment based on FIFO scheduling mechanism.
os_simple_priority_mutex similar to os_simple_mutex, but guarantees order of resource obtainment based on developer-driven priority mechanism.
os_counting_semaphore tracks multiple resources to be locked and unlocked.
os_read_write_semaphore protects a resource, limiting access to a single writer or multiple readers.
os_event_semaphore provides a signal device for group notification. Multiple threads block on a single semaphore, then all are released at the same time.
os_condition_mutex allows a single shared resource to be locked and unlocked, specifically an os_condition. Also called a nonrecursive mutex.

Semaphore Helpers

os_sem_lock synchronization mechanism that automatically releases/unlocks other semaphores when an object goes out of scope, similar to the way auto_ptr frees memory. This class is useful for developing exception-safe code.
os_sem_read_lock os_sem_lock that obtains a read lock when constructed.
os_sem_write_lock os_sem_lock that obtains a write lock when constructed.
os_monitor powerful nonintrusive mechanism that read- or write-locks an object. Monitors adorn other objects, attaching a read/write semaphore without requiring modification to the original code.
os_sentinel synchronization mechanism that provides nonintrusive locking on objects and change notification for multiple threads. Serves as a great foundation for agent technology.
os_barrier synchronization primitive that allows a specified number of threads to reach a specific point and wait before they all can proceed.
os_condition synchronization object that enables a thread to test an arbitrary condition and block until the state of the condition changes, all under the protection of a mutex.
os_ward synchronization mechanism that enables a thread to test several arbitrary conditions and block until one, any, or all conditions change.

Producer-Consumer Containers

os_pc_priorty_queue priority based producer consumer queue.
os_pc_queue FIFO based producer consumer queue.
os_pc_stack LIFO based producer consumer stack.

Library Initialization and Exception Handling

os_thread_toolkit provides automatic initialization of Thread<ToolKit>.
os_thread_toolkit_error exception class for reporting errors within Thread<ToolKit>.

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.