00001
00002
00003
00004
00005
00006
00007
00008 #include "DCPS/DdsDcps_pch.h"
00009 #include "SafetyProfilePool.h"
00010 #include "dds/DCPS/debug.h"
00011 #include <stdexcept>
00012
00013 #ifdef OPENDDS_SAFETY_PROFILE
00014 namespace OpenDDS { namespace DCPS {
00015
00016 SafetyProfilePool::SafetyProfilePool()
00017 : main_pool_(0)
00018 {
00019 }
00020
00021 SafetyProfilePool::~SafetyProfilePool()
00022 {
00023
00024
00025 }
00026
00027 void
00028 SafetyProfilePool::configure_pool(size_t size, size_t granularity)
00029 {
00030 ACE_GUARD(ACE_Thread_Mutex, lock, lock_);
00031
00032 if (main_pool_ == NULL) {
00033 main_pool_ = new MemoryPool(size, granularity);
00034 }
00035 }
00036
00037 void
00038 SafetyProfilePool::install()
00039 {
00040 if (ACE_Allocator::instance () != this) {
00041 ACE_Allocator::instance (this);
00042 }
00043 }
00044
00045 SafetyProfilePool*
00046 SafetyProfilePool::instance() {
00047 return instance_;
00048 }
00049
00050 SafetyProfilePool* SafetyProfilePool::instance_ = 0;
00051
00052 struct InstanceMaker {
00053 InstanceMaker() {
00054 SafetyProfilePool::instance_ = new SafetyProfilePool();
00055 }
00056
00057 ~InstanceMaker() {
00058 if (DCPS_debug_level) {
00059 if (SafetyProfilePool::instance_->main_pool_) {
00060 ACE_DEBUG((LM_INFO, "LWM: main pool: %d bytes\n",
00061 SafetyProfilePool::instance_->main_pool_->lwm_free_bytes()));
00062 }
00063 }
00064 }
00065
00066 };
00067
00068 InstanceMaker instance_maker_;
00069
00070 }}
00071
00072 #endif