rambrain
rambrain::dummyManagedMemory Class Reference

a dummy managed Memory that basically does nothing and throws on everything. More...

#include <dummyManagedMemory.h>

Inheritance diagram for rambrain::dummyManagedMemory:
rambrain::managedDummySwapContainer rambrain::managedMemory

Public Member Functions

 dummyManagedMemory ()
 
virtual ~dummyManagedMemory ()
 
- Public Member Functions inherited from rambrain::managedMemory
 managedMemory (managedSwap *swap, global_bytesize size=gig)
 Standard constructor. More...
 
virtual ~managedMemory ()
 
void closeSwap ()
 powers down the swap class, ergo a cleanup More...
 
bool setMemoryLimit (global_bytesize size)
 dynamically adjusts allowed ram usage More...
 
global_bytesize getMemoryLimit () const
 returns current memory limit More...
 
global_bytesize getUsedMemory () const
 returns current ram usage More...
 
global_bytesize getSwappedMemory () const
 returns current swap usage More...
 
global_bytesize getFreeSwapMemory () const
 return current swap free capacity More...
 
global_bytesize getTotalSwapMemory () const
 return current swap capacity More...
 
bool setOutOfSwapIsFatal (bool fatal=true)
 set policy what to do when out of memory in both ram and swap More...
 
bool prepareUse (rambrain::managedMemoryChunk &chunk, bool acquireLock=true)
 Triggers swapin of chunk. More...
 
bool setUse (memoryID id)
 Convenience interface for setUse( managedMemoryChunk &chunk, bool writeAccess ) More...
 
bool unsetUse (memoryID id)
 Convenience interface for unsetUse ( managedMemoryChunk &chunk, bool writeAccess ) More...
 
bool setUse (managedMemoryChunk &chunk, bool writeAccess)
 Marks chunk as used and prevents swapout. More...
 
bool unsetUse (managedMemoryChunk &chunk, unsigned int no_unsets=1)
 Marks chunk as unused again. More...
 
unsigned int getNumberOfChildren (const memoryID &id)
 conveniently returns number of children of the memoryChunk with id id More...
 
void printTree (managedMemoryChunk *current=NULL, unsigned int nspaces=0)
 prints the tree of managed objects for further inspection More...
 
void recursiveMfree (memoryID id)
 recursively deletes the objects in memory, first children, then parents. More...
 
void linearMfree ()
 linearly deletes all objects in memory More...
 
void printSwapstats () const
 print statistic about the number, size and efficiency of swapping actions More...
 
void resetSwapstats ()
 reset statistic about the number, size and efficiency of swapping actions More...
 
double getHitsOverMisses ()
 returns current hits over misses rate for accessing elements. More...
 
double getTotalSwappedOutBytes ()
 simple Getter More...
 
double getTotalSwappedInBytes ()
 simple Getter More...
 

Protected Member Functions

virtual swapErrorCode swapOut (global_bytesize)
 swaps out at least min_size bytes More...
 
virtual bool swapIn (managedMemoryChunk &)
 Tries to swap in chunk chunk. More...
 
virtual bool touch (managedMemoryChunk &)
 marks chunk as recently active as a hint for scheduling More...
 
virtual void untouch (managedMemoryChunk &)
 marks chunk as recently not needed any more More...
 
virtual void schedulerRegister (managedMemoryChunk &)
 gives scheduler code the opportunity to register its own datastructures associated with a chunk More...
 
virtual void schedulerDelete (managedMemoryChunk &)
 signals deletion of chunk to scheduler code More...
 
- Protected Member Functions inherited from rambrain::managedMemory
managedMemoryChunkmmalloc (global_bytesize sizereq)
 allocates and registers a new raw memory chunk of size sizereq to be filled in by managedPtr More...
 
bool mrealloc (memoryID id, global_bytesize sizereq)
 this function is a stub. In the future it should be capable of resizing an existing allocation More...
 
void mfree (rambrain::memoryID id, bool inCleanup=false)
 this function unregisters and deallocates a chunk More...
 
managedMemoryChunkresolveMemChunk (const memoryID &id)
 returns a reference to the memoryChunk indexed by id id More...
 
virtual bool swapIn (memoryID id)
 Convenience function for swapIn ( managedMemoryChunk &chunk ) More...
 
bool ensureEnoughSpace (global_bytesize sizereq, managedMemoryChunk *orIsSwappedin=NULL)
 This function ensures that there is sizereq space left in ram. More...
 
bool waitForSwapin (managedMemoryChunk &chunk, bool keepSwapLock=false)
 Waits until a certain chunk is present. More...
 
bool waitForSwapout (managedMemoryChunk &chunk, bool keepSwapLock=false)
 Waits until a certain chunk is swapped out. More...
 
void claimUsageof (global_bytesize bytes, bool rambytes, bool used)
 account for memory usage change More...
 
void claimTobefreed (global_bytesize bytes, bool tobefreed)
 account for future availability of bytes More...
 
void waitForAIO ()
 wait for some asynchronous action to occur More...
 

Additional Inherited Members

- Static Public Member Functions inherited from rambrain::managedMemory
static void signalSwappingCond ()
 signals that a swapping action has completed and memory limits have changed More...
 
static void sigswapstats (int sig)
 static binding that will print out some stats. Compile with cmake -DSWAPSTATS=on and send process SIGUSR1 to call this function More...
 
static void versionInfo ()
 prints out a GIT version info and a diff on this version at compile time More...
 
- Static Public Attributes inherited from rambrain::managedMemory
static const memoryID root = 1
 
static memoryID parent = managedMemory::root
 
static bool threadSynced = false
 
static pthread_mutex_t parentalMutex = PTHREAD_MUTEX_INITIALIZER
 
static pthread_cond_t parentalCond = PTHREAD_COND_INITIALIZER
 
static pthread_t creatingThread = 0
 
static managedMemorydefaultManager
 
static const memoryID invalid = 0
 
- Protected Types inherited from rambrain::managedMemory
enum  swapErrorCode { ERR_SUCCESS, ERR_SWAPFULL, ERR_MORETHANTOTALRAM, ERR_NOTENOUGHCANDIDATES }
 Error codes for swapOut requests. More...
 
- Static Protected Member Functions inherited from rambrain::managedMemory
static bool Throw (memoryException e)
 Custom throw function, as we need to prevent throwing exceptions in construtors. More...
 
- Protected Attributes inherited from rambrain::managedMemory
managedSwapswap = 0
 
global_bytesize memory_max
 
global_bytesize memory_used = 0
 
global_bytesize memory_swapped = 0
 
global_bytesize memory_tobefreed = 0
 
bool outOfSwapIsFatal = true
 
std::map< memoryID, managedMemoryChunk * > memChunks
 
memoryAtime atime = 0
 
memoryID memID_pace = 1
 
managedMemorypreviousManager
 
global_bytesize n_swap_out = 0
 
global_bytesize n_swap_in = 0
 
global_bytesize swap_out_scheduled_bytes = 0
 
global_bytesize swap_in_scheduled_bytes = 0
 
global_bytesize swap_out_bytes = 0
 
global_bytesize swap_in_bytes = 0
 
global_bytesize swap_out_bytes_last = 0
 
global_bytesize swap_in_bytes_last = 0
 
global_bytesize swap_hits = 0
 
global_bytesize swap_misses = 0
 
size_t memoryAlignment = 1
 
- Static Protected Attributes inherited from rambrain::managedMemory
static pthread_mutex_t stateChangeMutex = PTHREAD_MUTEX_INITIALIZER
 
static pthread_cond_t swappingCond = PTHREAD_COND_INITIALIZER
 
static FILE * logFile = fopen ( "rambrain-swapstats.log", "w" )
 
static bool firstLog = true
 
- Private Member Functions inherited from rambrain::managedDummySwapContainer
 managedDummySwapContainer ()
 
virtual ~managedDummySwapContainer ()
 
- Private Attributes inherited from rambrain::managedDummySwapContainer
managedDummySwap mswap
 

Detailed Description

a dummy managed Memory that basically does nothing and throws on everything.

Note
there is no productive use of this class, it only serves testing purposes

Definition at line 45 of file dummyManagedMemory.h.

Constructor & Destructor Documentation

rambrain::dummyManagedMemory::dummyManagedMemory ( )
inline

Definition at line 48 of file dummyManagedMemory.h.

virtual rambrain::dummyManagedMemory::~dummyManagedMemory ( )
inlinevirtual

Definition at line 49 of file dummyManagedMemory.h.

Member Function Documentation

virtual void rambrain::dummyManagedMemory::schedulerDelete ( managedMemoryChunk chunk)
inlineprotectedvirtual

signals deletion of chunk to scheduler code

Implements rambrain::managedMemory.

Definition at line 76 of file dummyManagedMemory.h.

virtual void rambrain::dummyManagedMemory::schedulerRegister ( managedMemoryChunk chunk)
inlineprotectedvirtual

gives scheduler code the opportunity to register its own datastructures associated with a chunk

Implements rambrain::managedMemory.

Definition at line 72 of file dummyManagedMemory.h.

virtual bool rambrain::dummyManagedMemory::swapIn ( managedMemoryChunk chunk)
inlineprotectedvirtual

Tries to swap in chunk chunk.

Returns
success
Parameters
chunkthe chunk subject to be swapped in Successful return does not mean that the chunk is available at an instant. It may be necessary for asynchronous swapIn to complete beforehands.
Note
this function must be called having stateChangeMutex acquired.

Implements rambrain::managedMemory.

Definition at line 57 of file dummyManagedMemory.h.

virtual swapErrorCode rambrain::dummyManagedMemory::swapOut ( global_bytesize  min_size)
inlineprotectedvirtual

swaps out at least min_size bytes

Returns
returns whether the swap out was successful or a reason why it was note
Parameters
min_sizeminimum size of swapped out elements Sucessful return does not mean that the bytes are available at an instant. It may be necessary for swapOut to complete beforehands.
Note
this function must be called having stateChangeMutex acquired.

Implements rambrain::managedMemory.

Definition at line 52 of file dummyManagedMemory.h.

virtual bool rambrain::dummyManagedMemory::touch ( managedMemoryChunk chunk)
inlineprotectedvirtual

marks chunk as recently active as a hint for scheduling

Implements rambrain::managedMemory.

Definition at line 62 of file dummyManagedMemory.h.

virtual void rambrain::dummyManagedMemory::untouch ( managedMemoryChunk chunk)
inlineprotectedvirtual

marks chunk as recently not needed any more

Implements rambrain::managedMemory.

Definition at line 67 of file dummyManagedMemory.h.


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