HeapRollingMultiplexingDataManager.cpp

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #include <fesa-core/Synchronization/HeapRollingMultiplexingDataManager.h>
00004 
00005 #include <fesa-core/Utilities/Mutex.h>
00006 
00007 
00008 namespace fesa
00009 {
00010 
00011 HeapRollingMultiplexingDataManager::HeapRollingMultiplexingDataManager(int32_t depth) :
00012     RollingMultiplexingDataManager(depth)
00013 {
00014 
00015 }
00016 
00017 int32_t HeapRollingMultiplexingDataManager::computeMemorySize()
00018 {
00019 
00020     int32_t memorySize = Mutex::getSize();
00021     // current index
00022     memorySize += static_cast<int32_t>(sizeof(int32_t));
00023     // current cycle id
00024     memorySize += static_cast<int32_t>(sizeof(int32_t));
00025     // cycles slots
00026     memorySize += static_cast<int32_t>(sizeof(int32_t)) * depth_;
00027     // cycle stamps
00028     memorySize += static_cast<int32_t>(sizeof(int64_t)) * depth_;
00029 
00030     return memorySize;
00031 }
00032 
00033 void HeapRollingMultiplexingDataManager::mapMemory(char* address)
00034 {
00035     mutex_ = new Mutex(address);
00036 
00037     currentPosition_ = (int32_t*) (address + Mutex::getSize());
00038 
00039     *currentPosition_ = 0;
00040 
00041     currentId_ = (int32_t*) ((char*) currentPosition_ + sizeof(int32_t));
00042 
00043     *currentId_ = -1;
00044 
00045     currentIdsCol_ = (int32_t*) ((char*) currentId_ + sizeof(int32_t));
00046 
00047     currentCycleStampsCol_ = (int64_t*) ((char*) currentIdsCol_ + (sizeof(int32_t) * depth_));
00048 }
00049 
00050 } // fesa

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1