ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
threadmap.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header file is part of module \alib_threads of the \aliblong.
4///
5/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
6/// Published under \ref mainpage_license "Boost Software License".
7//==================================================================================================
8#ifndef HPP_ALIB_THREADS_DETAIL_THREADMAP
9#define HPP_ALIB_THREADS_DETAIL_THREADMAP 1
10#pragma once
12#include <mutex>
13
14#if ALIB_MONOMEM && ALIB_CONTAINERS
17#else
18# include <unordered_map>
19#endif
20
21
22
23namespace alib { namespace threads { namespace detail {
24
25#if ALIB_MONOMEM && ALIB_CONTAINERS
26
27 /// The hash map used to find the current thread object.
28 /// The object uses default values for \alib{containers;HashTable::BaseLoadFactor} and
29 /// \alib{containers;HashTable::MaxLoadFactor}. Depending on the use of threads by a
30 /// using application, these values might be modified \e before starting the first phase of
31 /// \ref alib_manual_bootstrapping "bootstrapping ALib".
32 ///
33 /// If so, an initial call to \alib{containers;HashTable::Reserve} may be likewise be performed.
34 ///
35 /// \note
36 /// With the absence of module \alib_monomem in the \alibdist, the type of this object
37 /// is <c>std::unordered_map</c>.
39
40#else
41 extern ALIB_API std::unordered_map< std::thread::id, Thread*> THREAD_MAP;
42#endif
43
44#if (!ALIB_MONOMEM || !ALIB_CONTAINERS) || DOXYGEN
45/// The internal mutex used with operations like starting, ending or finding thread objects.
46///
47/// \note
48/// With the presence of module \alib_monomem in the \alibdist, this object is not available.
49/// Instead, \alib{monomem;GLOBAL_ALLOCATOR_LOCK} is used, because this likewise protects
50/// modifications on object \alib{threads;detail::THREAD_MAP}, which uses this allocator.
51extern ALIB_API std::mutex MODULE_LOCK;
52#endif
53
54/// Internal method to start a thread.
55/// @param thread The \alib thread object to start.
56void threadStart( Thread* thread );
57
58}}} // namespace [alib::threads::detail]
59
60#endif // HPP_ALIB_THREADS_DETAIL_THREADMAP
61
#define ALIB_API
Definition alib.hpp:639
ALIB_API std::mutex MODULE_LOCK
void threadStart(Thread *thread)
Definition thread.cpp:73
ALIB_API HashMap< MonoAllocator, std::thread::id, Thread * > THREAD_MAP
Directory which assigns system thread IDs to ALib Thread objects.
Definition thread.cpp:62
Definition alib.cpp:69