ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
globalallocator.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header file is part of module \alib_monomem 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_MONOMEM_GLOBALALLOCATOR
9#define HPP_ALIB_MONOMEM_GLOBALALLOCATOR 1
10#pragma once
11#if !defined(DOXYGEN)
12# include "alib/alib.hpp"
13#endif
14ALIB_ASSERT_MODULE(MONOMEM)
15#include "alib/monomem/monoallocator.hpp"
16
17#if ALIB_THREADS
19#endif
20
21namespace alib::monomem {
22
23/// This is the global monotonic allocator singleton instance.
24/// It's initial size defaults to \ 128 kilobytes. This can be tweaked by performing a
25/// placement-new on this instance before \ref alib_manual_bootstrapping "bootstrapping ALib".
26///
27/// \see
28/// - Chapter \ref alib_contmono_globalinstance of the Programmer's Manual of this \alibmod_nl.
29/// - \b Lock instance \alib{monomem::GLOBAL_ALLOCATOR_LOCK}
31
32#if ALIB_THREADS
33 /// This <em>mutex</em> is used to protect the \alib{monomem;GLOBAL_ALLOCATOR} from racing
34 /// conditions in multithreaded software.<br>
35 /// If compiler symbol \ref ALIB_DEBUG_CRITICAL_SECTIONS is set, this lock will be attached
36 /// to the \alib{lang;DbgCriticalSections} instance in #GLOBAL_ALLOCATOR during bootstrap.
37 /// Thus, an assertion will be raised if the \alib{monomem;GLOBAL_ALLOCATOR} is used without
38 /// locking this mutex.<br>
39 /// This is a recursive lock.
40 /// This allows using the \alib{lang;AllocatorInterface;high-level allocation interface} with
41 /// allocations, which constructs objects.
42 /// These objects might recursively use the global allocator for their members.
44#endif
45
46} // namespace [alib::monomem]
47
48#endif // HPP_ALIB_MONOMEM_GLOBALALLOCATOR
49
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:223
#define ALIB_API
Definition alib.hpp:639
ALIB_API MonoAllocator GLOBAL_ALLOCATOR
ALIB_API RecursiveLock GLOBAL_ALLOCATOR_LOCK
monomem::TMonoAllocator< lang::HeapAllocator > MonoAllocator
threads::RecursiveLock RecursiveLock
Type alias in namespace alib.