ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::threads Namespace Reference

Description:

This is the reference documentation of namespace threads of the ALib C++ Library, which holds types of library module ALib Threads.

Attention
At the moment the compiler-symbol ALIB_SINGLE_THREADED is set with an ALib Build, this module will remain in the build, but only as skeletons. Also, the corresponding preprocessor macros, like ALIB_LOCK, are emptied.
This allows writing dual-use code which compiles in either mode, without checking symbol ALIB_SINGLE_THREADED in the using code too often.

Further documentation is provided with

Nested Namespaces:

namespace  detail
 Details of namespace alib::threads.
 

Type Index:

class  Condition
 
struct  DbgConditionAsserter
 
struct  DbgLockAsserter
 
struct  DbgSharedLockAsserter
 
class  Lock
 
class  Promise
 
class  RecursiveLock
 
class  RecursiveTimedLock
 
class  Runnable
 
class  SharedLock
 
class  SharedTimedLock
 
struct  TCondition
 
class  Thread
 
class  TimedLock
 

Type Definition Index:

using ThreadID = integer
 The ALib thread identifier type.
 

Function Index:

void bootstrap ()
 
void BootstrapThreadMap (integer qty)
 
void shutdown ()
 

Variable Index:

ALIB_DLL Lock STD_IOSTREAMS_LOCK
 
thread_local ThreadTHIS_THREAD = nullptr
 A thread-local pointer to the ALib representation of the actual thread.
 
constexpr ThreadID UNDEFINED = 0
 This is a value that may be passed as a value indicating an undefined thread.
 

Type Definition Details:

◆ ThreadID

The ALib thread identifier type.

Definition at line 23 of file thread.inl.

Function Details:

◆ bootstrap()

ALIB_DLL void alib::threads::bootstrap ( )

Initializes ALib thread logic. Multiple invocations of this method are forbidden.

The standard bootstrap code of ALib, hence the (overloaded) functions alib::Bootstrap will call this function.

See also
For information about using this method, consult chapter 3. Bootstrapping Non-Camp Modules of the ALib Programmer's Manual.

Definition at line 138 of file thread.cpp.

Here is the call graph for this function:

◆ BootstrapThreadMap()

ALIB_DLL void alib::threads::BootstrapThreadMap ( integer qty)

Internally, a hash map used to find the current thread object. The map uses default values for HashTable::BaseLoadFactor and HashTable::MaxLoadFactor. Depending on the use of threads by a using application, these values might be modified before starting the first phase of bootstrapping ALib.

This namespace function allows doing this by passing the given parameters to method HashTable::Reserve of the internal table.

Note
With the absence of module ALib Monomem in the ALib Build, the type of the internal object is std::unordered_map, which receives similar parameters.
Parameters
qtyThe expected number of threads.

Definition at line 131 of file thread.cpp.

◆ shutdown()

ALIB_DLL void alib::threads::shutdown ( )

Frees resources and shuts down ALib thread logic. Multiple invocations of this method are forbidden. The standard bootstrap code of ALib, hence the (overloaded) functions alib::Shutdown will call this function.

See also
Sibling function Bootstrap.

Definition at line 161 of file thread.cpp.

Here is the call graph for this function:

Variable Details:

◆ STD_IOSTREAMS_LOCK

Lock alib::threads::STD_IOSTREAMS_LOCK

This global mutex is acquired by ALib-types, whenever data is written to either std::cout or std::cerr. This is, for example, acquired by function alib::assert::Raise and by loggers of module ALox that log to the console.

Definition at line 44 of file locks.cpp.

◆ THIS_THREAD

thread_local Thread * alib::threads::THIS_THREAD = nullptr

A thread-local pointer to the ALib representation of the actual thread.

Definition at line 219 of file thread.cpp.

◆ UNDEFINED

ThreadID alib::threads::UNDEFINED = 0
inlineconstexpr

This is a value that may be passed as a value indicating an undefined thread.

Definition at line 29 of file thread.inl.