ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
TSharedConfiguration< TLock > Class Template Reference

Description:

template<typename TLock>
class alib::config::TSharedConfiguration< TLock >

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.

Template Parameters
TLockThe 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>

Inheritance diagram for TSharedConfiguration< TLock >:
[legend]
Collaboration diagram for TSharedConfiguration< TLock >:
[legend]

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 ConfigurationGet () const noexcept
 
ConfigurationGet () noexcept
 
AllocatorTypeGetAllocator () noexcept
 
TLock & GetLock () const noexcept
 
bool IsNulled () const noexcept
 
 operator bool () const noexcept
 
bool operator!= (std::nullptr_t) const noexcept
 
const Configurationoperator* () const noexcept
 
Configurationoperator* () noexcept
 
const Configurationoperator-> () const noexcept
 
Configurationoperator-> () noexcept
 
TSharedMonoValoperator= (const TSharedMonoVal &other) noexcept
 
void operator= (std::nullptr_t)
 Assignment of nullptr. Same as SetNulled.
 
TSharedMonoValoperator= (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 ConfigurationSelf () const noexcept
 
ConfigurationSelf () 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 >
FieldMembersmembers
 

Type Definition Details:

◆ Base

template<typename TLock >
using Base = monomem::TSharedMonoVal<Configuration, HeapAllocator, TLock>
private

Exposed shortcut to the base type.

Definition at line 1362 of file configuration.hpp.

Constructor(s) / Destructor Details:

◆ TSharedConfiguration() [1/2]

template<typename TLock >
TSharedConfiguration ( std::nullptr_t )
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.

◆ TSharedConfiguration() [2/2]

template<typename TLock >
TSharedConfiguration ( size_t initialBufferSizeInKB,
unsigned int bufferGrowthInPercent = 200,
lang::CreateDefaults createDefaults = lang::CreateDefaults::Yes )
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.

Parameters
initialBufferSizeInKBThe initial size of memory buffers. Passed to the allocator given with parent class TSharedMonoVal.
bufferGrowthInPercentOptional 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.
createDefaultsDetermines if default plug-ins are to be created. Defaults to Yes.

Definition at line 1390 of file configuration.hpp.

◆ ~TSharedConfiguration()

template<typename TLock >
~TSharedConfiguration ( )
inline

Destructor. Calls DbgCriticalSections to stop checking the integrated TLock.

Definition at line 1404 of file configuration.hpp.

Method Details:

◆ DbgCriticalSections()

template<typename TLock >
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).

Parameters
onOffThe switch.

◆ Reset()

template<typename TLock >
void Reset ( lang::CreateDefaults createDefaults = lang::CreateDefaults::Yes)
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).

Parameters
createDefaultsDetermines if default plug-ins are to be created. Defaults to Yes.

Definition at line 1441 of file configuration.hpp.


The documentation for this class was generated from the following file: