thread |
A thread is a program that is
executing. A thread can access almost all of its own attributes, but can access
only a small subset of other threads' attributes. Therefore, thread objects are
modeled using two classes: os_this_thread , which
represents the current thread, and os_thread ,
which represents other threads.
To create a new thread, construct
an os_thread with the address of a function and a
pointer to an optional argument. This creates a thread that executes the
specified function with the supplied pointer as its argument. The function must
be able to take a void* argument and return a void*
.
Once constructed, an os_thread
object contains functions that allow you to suspend, resume, terminate, and
change the priority of the thread object. The new thread executes concurrently
with other threads in the process and terminates when it reaches the end of the
specified function.
A thread is associated with a
priority defined by the enumeration defined below. This enumerator is scoped in
the class os_thread_priority . A thread priority is
defined by a level_t to allow portable
prioritization across most major platforms.
Conversions allow os_thread
and os_thread_t to be used interchangeably.
typedef void* (*os_thread_func_t)( void* arg )
// Pointer to a function that takes a void* argument and returns a void*.
0
). The default value for detached (default false
) causes the thread to run nondetached. The default value for stack_size
(default 0 ) causes a default stack size
allocation for the thread. If detached is false
, the thread termination can be detected using os_this_thread::wait_for_thread()
or os_this_thread::wait_for_any_thread(). Throws: os_thread_toolkit_error
void* run()
method of runnable . The default value for detached
(default false ) causes the thread to run
nondetached. The default value for stack_size
(default 0 ) causes a default stack size
allocation for the thread. If detached is false
, the thread termination can be detected using os_this_thread::wait_for_thread()
or os_this_thread::wait_for_any_thread(). Note
that the compiler must be able to support member templates and
OS_ENABLE_MEMBER_TEMPLATE_FEATURES must be defined to use this member
function.Throws: os_thread_toolkit_error
true
if the thread ID is less than thread 's.true
if the thread ID is equal to thread 's.os_thread constructor. Throws: os_thread_toolkit_error
os_thread constructor. Throws: os_thread_toolkit_error
true
if the thread represents a thread that has not terminated. Throws: os_thread_toolkit_error
Throws: os_thread_toolkit_error
Throws: os_thread_toolkit_error
Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.