rambrain
rambrain::managedPtr< T, 1 > Class Template Reference

Main class to allocate memory that is managed by the rambrain memory defaultManager in a multidimensional way given by the second template parameter. More...

#include <managedPtr.h>

Public Member Functions

 managedPtr (const managedPtr< T, 1 > &ref)
 copy ctor More...
 
 managedPtr ()
 with no arguments given, instantiates an array with one element More...
 
template<typename... ctor_args>
 managedPtr (unsigned int n_elem, ctor_args...Args)
 instantiates managedPtr containing n_elem elements and passes Args as arguments to the constructor of these More...
 
 ~managedPtr ()
 destructor More...
 
unsigned int size () const
 Simple getter. More...
 
bool prepareUse () const
 tells the memory manager to possibly swap in chunk for near future use More...
 
bool setUse (bool writable=true, bool *tracker=NULL) const
 Atomically sets use to a chunk if tracker is not already set to true. returns whether we set use or not. More...
 
bool unsetUse (unsigned int loaded=1) const
 unsets use count on memory chunk More...
 
managedPtr< T > & operator= (const managedPtr< T, 1 > &ref)
 assignment operator More...
 
DEPRECATED T & operator[] (int i)
 
DEPRECATED const T & operator[] (int i) const
 
T * getLocPtr () const
 returns local pointer to object More...
 
const T * getConstLocPtr () const
 returns const local pointer to object More...
 

Private Member Functions

template<class G >
std::enable_if< std::is_class< G >::value >::type mDelete () const
 This function manages correct deallocation for array elements having a destructor. More...
 
template<class G >
std::enable_if< !std::is_class< G >::value >::type mDelete ()
 This function manages correct deallocation for array elements lacking a destructor. More...
 
void waitForSwapin () const
 : indefinitely waits for swapin of the chunk While it would have been desirable to throw exceptions when chunk is not available, checking this in a save way would produce lots of overhead. Thus, it is better to wait indefinitely in this case, as under normal use, the chunk will become available. More...
 

Private Attributes

managedMemoryChunkchunk
 
unsigned int * tracker
 
unsigned int n_elem
 

Friends

template<class G >
class adhereTo
 
template<class G >
class adhereToConst
 
class ::managedPtr_Unit_ChunkInUse_Test
 
class ::managedPtr_Unit_GetLocPointer_Test
 
class ::managedPtr_Unit_SmartPointery_Test
 
class ::managedFileSwap_Unit_SwapSingleIsland_Test
 
class ::managedFileSwap_Unit_SwapNextAndSingleIsland_Test
 
class ::adhereTo_Unit_TwiceAdheredOnceUsed_Test
 

Detailed Description

template<class T>
class rambrain::managedPtr< T, 1 >

Main class to allocate memory that is managed by the rambrain memory defaultManager in a multidimensional way given by the second template parameter.

Warning
thread-safety
  • The object itself is not thread-safe
  • Do not pass pointers/references to this object over thread boundaries
Note
thread-safety
  • The object itself may be passed over thread boundary

Definition at line 145 of file managedPtr.h.

Constructor & Destructor Documentation

template<class T >
rambrain::managedPtr< T, 1 >::managedPtr ( const managedPtr< T, 1 > &  ref)
inline

copy ctor

Definition at line 149 of file managedPtr.h.

template<class T >
rambrain::managedPtr< T, 1 >::managedPtr ( )
inline

with no arguments given, instantiates an array with one element

Definition at line 154 of file managedPtr.h.

template<class T >
template<typename... ctor_args>
rambrain::managedPtr< T, 1 >::managedPtr ( unsigned int  n_elem,
ctor_args...  Args 
)
inline

instantiates managedPtr containing n_elem elements and passes Args as arguments to the constructor of these

I admit, this is a bit complicated. as we do not want users to carry around information about object parenthood into their classes, we have to ensure that our 'memoryManager::parent' attribute is carried down the hierarchy correctly. As this code part is accessed recursively throughout creation, we have to make sure that we do not lock twice (deadlock) we only continue if we're called by the currently active creation process the following is not very elegant, but works. The idea behind this is that we admit one thread at a time to create an object class hierarchy. In this way, the parent argument from below is correct. This is synced by basically checking wether we should be a master or not based on a possibly setted threadID...

Definition at line 158 of file managedPtr.h.

template<class T >
rambrain::managedPtr< T, 1 >::~managedPtr ( )
inline

destructor

Definition at line 226 of file managedPtr.h.

Member Function Documentation

template<class T >
const T* rambrain::managedPtr< T, 1 >::getConstLocPtr ( ) const
inline

returns const local pointer to object

Note
when called, you have to care for setting use to the chunk, first

Definition at line 304 of file managedPtr.h.

template<class T >
T* rambrain::managedPtr< T, 1 >::getLocPtr ( ) const
inline

returns local pointer to object

Note
when called, you have to care for setting use to the chunk, first

Definition at line 294 of file managedPtr.h.

template<class T >
template<class G >
std::enable_if<std::is_class<G>::value>::type rambrain::managedPtr< T, 1 >::mDelete ( ) const
inlineprivate

This function manages correct deallocation for array elements having a destructor.

Definition at line 319 of file managedPtr.h.

template<class T >
template<class G >
std::enable_if< !std::is_class<G>::value >::type rambrain::managedPtr< T, 1 >::mDelete ( )
inlineprivate

This function manages correct deallocation for array elements lacking a destructor.

Definition at line 334 of file managedPtr.h.

template<class T >
managedPtr<T>& rambrain::managedPtr< T, 1 >::operator= ( const managedPtr< T, 1 > &  ref)
inline

assignment operator

Definition at line 262 of file managedPtr.h.

template<class T >
DEPRECATED T& rambrain::managedPtr< T, 1 >::operator[] ( int  i)
inline
Note
This operator can only be called safely in single threaded situations when preemptive swapOut actions have been disabled

Definition at line 279 of file managedPtr.h.

template<class T >
DEPRECATED const T& rambrain::managedPtr< T, 1 >::operator[] ( int  i) const
inline
Note
This operator can only be called safely in single threaded situations when preemptive swapOut actions have been disabled

Definition at line 285 of file managedPtr.h.

template<class T >
bool rambrain::managedPtr< T, 1 >::prepareUse ( ) const
inline

tells the memory manager to possibly swap in chunk for near future use

Definition at line 239 of file managedPtr.h.

template<class T >
bool rambrain::managedPtr< T, 1 >::setUse ( bool  writable = true,
bool *  tracker = NULL 
) const
inline

Atomically sets use to a chunk if tracker is not already set to true. returns whether we set use or not.

Definition at line 245 of file managedPtr.h.

template<class T >
unsigned int rambrain::managedPtr< T, 1 >::size ( ) const
inline

Simple getter.

Definition at line 234 of file managedPtr.h.

template<class T >
bool rambrain::managedPtr< T, 1 >::unsetUse ( unsigned int  loaded = 1) const
inline

unsets use count on memory chunk

Definition at line 257 of file managedPtr.h.

template<class T >
void rambrain::managedPtr< T, 1 >::waitForSwapin ( ) const
inlineprivate

: indefinitely waits for swapin of the chunk While it would have been desirable to throw exceptions when chunk is not available, checking this in a save way would produce lots of overhead. Thus, it is better to wait indefinitely in this case, as under normal use, the chunk will become available.

Definition at line 346 of file managedPtr.h.

Friends And Related Function Documentation

template<class T >
friend class ::adhereTo_Unit_TwiceAdheredOnceUsed_Test
friend

Definition at line 372 of file managedPtr.h.

template<class T >
friend class ::managedFileSwap_Unit_SwapNextAndSingleIsland_Test
friend

Definition at line 371 of file managedPtr.h.

template<class T >
friend class ::managedFileSwap_Unit_SwapSingleIsland_Test
friend

Definition at line 370 of file managedPtr.h.

template<class T >
friend class ::managedPtr_Unit_ChunkInUse_Test
friend

Definition at line 367 of file managedPtr.h.

template<class T >
friend class ::managedPtr_Unit_GetLocPointer_Test
friend

Definition at line 368 of file managedPtr.h.

template<class T >
friend class ::managedPtr_Unit_SmartPointery_Test
friend

Definition at line 369 of file managedPtr.h.

template<class T >
template<class G >
friend class adhereTo
friend

Definition at line 361 of file managedPtr.h.

template<class T >
template<class G >
friend class adhereToConst
friend

Definition at line 363 of file managedPtr.h.

Member Data Documentation

template<class T >
managedMemoryChunk* rambrain::managedPtr< T, 1 >::chunk
private

Definition at line 312 of file managedPtr.h.

template<class T >
unsigned int rambrain::managedPtr< T, 1 >::n_elem
private

Definition at line 314 of file managedPtr.h.

template<class T >
unsigned int* rambrain::managedPtr< T, 1 >::tracker
private

Definition at line 313 of file managedPtr.h.


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