00001
00002
00003
00004
00005
00006
00007
00008 #ifndef DATABLOCKLOCKPOOL_H
00009 #define DATABLOCKLOCKPOOL_H
00010
00011 #include "ace/Lock_Adapter_T.h"
00012 #include "ace/Thread_Mutex.h"
00013 #include "ace/Containers_T.h"
00014 #include "dcps_export.h"
00015 #include "dds/DCPS/PoolAllocationBase.h"
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 class OpenDDS_Dcps_Export DataBlockLockPool : public OpenDDS::DCPS::PoolAllocationBase {
00029 public:
00030 typedef ACE_Lock_Adapter<ACE_Thread_Mutex> DataBlockLock;
00031
00032 DataBlockLockPool(unsigned long size)
00033 : pool_(size),
00034 size_(size),
00035 iterator_(0)
00036 {
00037 }
00038
00039 ~DataBlockLockPool() { }
00040
00041 DataBlockLock * get_lock() {
00042 unsigned long index = iterator_++ % size_;
00043 return &(pool_[index]);
00044 }
00045
00046 private:
00047 typedef ACE_Array<DataBlockLock> Pool;
00048
00049 Pool pool_;
00050 const unsigned long size_;
00051
00052 ACE_Atomic_Op<ACE_Thread_Mutex, unsigned long> iterator_;
00053 };
00054
00055 #endif