Utility type which implements TSharedMonoVal with class Configuration. The result of combining both is an automatic pointer to a Configuration that is "self-contained" in the first buffer of a MonoAllocator together with the allocator itself. All configuration variables are deleted and all associated memory is freed when the last copy of the pointer goes out of scope.
Along with the Configuration, this shared object includes a SharedLock. See chapter 7.4 Locking Shared Values of the Programmer's Manual of module ALib Monomem for further information on how to protect the contents of this type against thread-racing-conditions.
TLock | The lock type passed to the template parameter of parent type TSharedMonoVal with the same name. With the inclusion of module ALib Threads in the ALib Distribution, the type-alias alib::SharedConfiguration chooses type SharedLock. Otherwise, in case ALib is compiled without threading support, the alias chooses void .If it is assured that no racing-conditions occur with shared instances in multithreaded software, the using code may pass void here as well. |
Definition at line 1359 of file configuration.hpp.
#include <configuration.hpp>
Public Method Index: | |
TSharedConfiguration ()=default | |
Constructs an empty instance, hence a cleared automatic pointer. | |
TSharedConfiguration (size_t initialBufferSizeInKB, unsigned int bufferGrowthInPercent=200, lang::CreateDefaults createDefaults=lang::CreateDefaults::Yes) | |
TSharedConfiguration (std::nullptr_t) noexcept | |
~TSharedConfiguration () | |
void | DbgCriticalSections (lang::Switch onOff) |
void | Reset (lang::CreateDefaults createDefaults=lang::CreateDefaults::Yes) |
Public Method Index: inherited from TSharedMonoVal< Configuration, HeapAllocator, TLock > | |
TSharedMonoVal () noexcept | |
Default Constructor. Leaves this object nulled. | |
TSharedMonoVal (const TSharedMonoVal &other) noexcept | |
TSharedMonoVal (HeapAllocator &allocator, size_t initialBufferSizeInKB, unsigned int bufferGrowthInPercent) | |
TSharedMonoVal (size_t initialBufferSizeInKB, unsigned int bufferGrowthInPercent) | |
TSharedMonoVal (std::nullptr_t) noexcept | |
TSharedMonoVal (TSharedMonoVal &&other) noexcept | |
~TSharedMonoVal () | |
void | Acquire (const CallerInfo &ci) const noexcept |
void | AcquireRecursive (const CallerInfo &ci) const noexcept |
void | AcquireShared (const CallerInfo &ci) const noexcept |
void | ConstructT (TArgs &&... args) |
const Configuration * | Get () const noexcept |
Configuration * | Get () noexcept |
AllocatorType & | GetAllocator () noexcept |
TLock & | GetLock () const noexcept |
bool | IsNulled () const noexcept |
operator bool () const noexcept | |
bool | operator!= (std::nullptr_t) const noexcept |
const Configuration & | operator* () const noexcept |
Configuration & | operator* () noexcept |
const Configuration * | operator-> () const noexcept |
Configuration * | operator-> () noexcept |
TSharedMonoVal & | operator= (const TSharedMonoVal &other) noexcept |
void | operator= (std::nullptr_t) |
Assignment of nullptr . Same as SetNulled. | |
TSharedMonoVal & | operator= (TSharedMonoVal &&other) noexcept |
bool | operator== (std::nullptr_t) const noexcept |
void | Release (const CallerInfo &ci) const noexcept |
void | ReleaseRecursive (const CallerInfo &ci) const noexcept |
void | ReleaseShared (const CallerInfo &ci) const noexcept |
void | Reset (TArgs &&... args) |
const Configuration & | Self () const noexcept |
Configuration & | Self () noexcept |
void | SetNulled () noexcept |
bool | TryAcquire (const CallerInfo &ci) const noexcept |
bool | TryAcquireShared (const CallerInfo &ci) const noexcept |
bool | TryAcquireSharedTimed (const Ticks &pointInTime, const CallerInfo &ci) const noexcept |
bool | TryAcquireSharedTimed (const Ticks::Duration &waitDuration, const CallerInfo &ci) const noexcept |
bool | TryAcquireSharedTimed (const Ticks::Duration::TDuration &waitDuration, const CallerInfo &ci) const noexcept |
bool | TryAcquireSharedTimed (const Ticks::TTimePoint &pointInTime, const CallerInfo &ci) const noexcept |
bool | TryAcquireTimed (const Ticks &pointInTime, const CallerInfo &ci) const noexcept |
bool | TryAcquireTimed (const Ticks::Duration &waitDuration, const CallerInfo &ci) const noexcept |
bool | TryAcquireTimed (const Ticks::Duration::TDuration &waitDuration, const CallerInfo &ci) const noexcept |
bool | TryAcquireTimed (const Ticks::TTimePoint &pointInTime, const CallerInfo &ci) const noexcept |
bool | Unique () const noexcept |
unsigned int | UseCount () const noexcept |
Private Type Index: | |
using | Base = monomem::TSharedMonoVal<Configuration, HeapAllocator, TLock> |
Exposed shortcut to the base type. | |
Additional Inherited Members | |
Public Type Index: inherited from TSharedMonoVal< Configuration, HeapAllocator, TLock > | |
using | AllocatorType |
Exposes the monotonic allocator used. Equals to TMonoAllocator<TAllocator> . | |
using | LockType |
Exposes the lock type specified with template parameter TLock. | |
using | StoredType |
Exposes the stored type specified with template parameter T. | |
Public Static Method Index: inherited from TSharedMonoVal< Configuration, HeapAllocator, TLock > | |
static constexpr size_t | SizeOfAllocation () |
Protected Type Index: inherited from TSharedMonoVal< Configuration, HeapAllocator, TLock > | |
using | FieldMembers |
Protected Field Index: inherited from TSharedMonoVal< Configuration, HeapAllocator, TLock > | |
FieldMembers * | members |
|
private |
Exposed shortcut to the base type.
Definition at line 1362 of file configuration.hpp.
|
inlinenoexcept |
Constructs an empty instance from std::nullptr
. This constructor is necessary to allow assignment of nullptr
to values of this type, which clears the automatic pointer.
Definition at line 1371 of file configuration.hpp.
|
inline |
Constructor. Calls the constructor of parent TSharedMonoVal and then invokes TSharedMonoVal::ConstructT passing the mono allocator that the parent creates this instance in.
Furthermore calls DbgCriticalSections to enable assertions to locked usage.
initialBufferSizeInKB | The initial size of memory buffers. Passed to the allocator given with parent class TSharedMonoVal. |
bufferGrowthInPercent | Optional growth factor in percent, applied to the buffer size with each next buffer allocation. Should be set to 200 , to double the size with each allocation. Defaults to 200 . Passed to the allocator given with parent class TSharedMonoVal. |
createDefaults | Determines if default plug-ins are to be created. Defaults to Yes . |
Definition at line 1390 of file configuration.hpp.
|
inline |
Destructor. Calls DbgCriticalSections to stop checking the integrated TLock.
Definition at line 1404 of file configuration.hpp.
void DbgCriticalSections | ( | lang::Switch | onOff | ) |
Enables or disables critical section checks between the contained T and the likewise contained TLock.
In case TLock equals void
or if symbol ALIB_DEBUG_CRITICAL_SECTIONS is not set, this method is empty (and its use is optimized out).
onOff | The switch. |
|
inline |
Clears all data, plugins, type-registrations, etc., from this configuration. Then this object is reinitialized to its constructor defaults.
The MonoAllocator of the parent class is likewise reset.
All shared instances remain valid (while, of-course, their content is likewise reset).
createDefaults | Determines if default plug-ins are to be created. Defaults to Yes . |
Definition at line 1441 of file configuration.hpp.