ALib C++ Framework
by
Library Version: 2511 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++ Framework, which holds types of library module ALib Threads.

Attention
At the moment the configuration macro 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:

struct  DbgConditionAsserter
struct  DbgLockAsserter
struct  DbgSharedLockAsserter
class  Event
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:

Lock STD_IOSTREAMS_LOCK
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()

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 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 137 of file thread.cpp.

◆ BootstrapThreadMap()

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

Internally, a hash map used to find the current thread object. The map uses default values for float BaseLoadFactor() const  and float MaxLoadFactor() const . 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 void Reserve(integer, lang::ValueReference)  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 130 of file thread.cpp.

◆ shutdown()

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 Shutdown will call this function.

See also
Sibling function bootstrap.

Definition at line 160 of file thread.cpp.

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 (see here).

The utility type OStreamWriter uses this lock as well as C++20 type std::basic_osyncstream (if available with the toolchain used) to have maximum protection in respect to writing to the console.

Definition at line 48 of file locks.cpp.

◆ THIS_THREAD

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

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

Definition at line 215 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.