Utility type which implements TSharedMonoVal with class FTree. The result of combining both is an automatic pointer to a FTree that is "self-contained" in the first buffer of a MonoAllocator together with the allocator itself. The tree is deleted and all associated memory is freed when the last copy of the pointer goes out of scope.
Along with the FTree, 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::SharedFTree 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. |
#include <ftree.hpp>
Public Type Index: | |
using | Base = monomem::TSharedMonoVal<FTree, HeapAllocator, TLock> |
Exposed shortcut to the base type. | |
![]() | |
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 Method Index: | |
TSharedFTree ()=default | |
Constructs an empty instance, hence a cleared automatic pointer. | |
TSharedFTree (size_t initialBufferSizeInKB, unsigned int bufferGrowthInPercent=200) | |
TSharedFTree (std::nullptr_t) noexcept | |
~TSharedFTree () | |
void | DbgCriticalSections (lang::Switch onOff) |
TSharedFTree & | operator= (const TSharedFTree &)=default |
void | Reset () |
![]() | |
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 FTree * | Get () const noexcept |
FTree * | 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 FTree & | operator* () const noexcept |
FTree & | operator* () noexcept |
const FTree * | operator-> () const noexcept |
FTree * | 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 FTree & | Self () const noexcept |
FTree & | 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 |
Additional Inherited Members | |
![]() | |
static constexpr size_t | SizeOfAllocation () |
![]() | |
using | FieldMembers |
![]() | |
FieldMembers * | members |
using Base = monomem::TSharedMonoVal<FTree, HeapAllocator, TLock> |
|
inlinenoexcept |
|
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. Passed to the allocator given with parent class TSharedMonoVal. Should be set to 200 , to double the size with each allocation. Defaults to 200 . |
Definition at line 535 of file ftree.hpp.
|
inline |
Destructor. Calls DbgCriticalSections to stop checking the integrated TLock.
Definition at line 550 of file ftree.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. |
|
default |
Defaulted copy-assignment operator.
this
.
|
inline |
Clears all scanned or otherwise inserted data and re-initializes this object to its constructor defaults and resets the MonoAllocator of the parent class.
All shared instances remain valid (while, of-course, their content is likewise reset).
Definition at line 592 of file ftree.hpp.