OpenDDS  Snapshot(2023/04/28-20:55)
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
DataBlockLockPool Class Reference

Holds and distributes locks to be used for locking ACE_Data_Blocks. Currently it does not require returning the locks. More...

#include <DataBlockLockPool.h>

Inheritance diagram for DataBlockLockPool:
Inheritance graph
[legend]
Collaboration diagram for DataBlockLockPool:
Collaboration graph
[legend]

Public Types

typedef ACE_Lock_Adapter< ACE_Thread_MutexDataBlockLock
 

Public Member Functions

 DataBlockLockPool (unsigned long size)
 
 ~DataBlockLockPool ()
 
DataBlockLockget_lock ()
 

Private Types

typedef ACE_Array< DataBlockLockPool
 

Private Attributes

Pool pool_
 
const unsigned long size_
 
OpenDDS::DCPS::Atomic< unsigned long > iterator_
 Counter used to track which lock to give out next (modulus size_) More...
 

Detailed Description

Holds and distributes locks to be used for locking ACE_Data_Blocks. Currently it does not require returning the locks.

: The lock returned is not guaranteed to be unique.

: This class is thread safe.

Definition at line 30 of file DataBlockLockPool.h.

Member Typedef Documentation

◆ DataBlockLock

Definition at line 32 of file DataBlockLockPool.h.

◆ Pool

Definition at line 49 of file DataBlockLockPool.h.

Constructor & Destructor Documentation

◆ DataBlockLockPool()

DataBlockLockPool::DataBlockLockPool ( unsigned long  size)
inline

Definition at line 34 of file DataBlockLockPool.h.

35  : pool_(size),
36  size_(size),
37  iterator_(0)
38  {
39  }
OpenDDS::DCPS::Atomic< unsigned long > iterator_
Counter used to track which lock to give out next (modulus size_)
const unsigned long size_

◆ ~DataBlockLockPool()

DataBlockLockPool::~DataBlockLockPool ( )
inline

Definition at line 41 of file DataBlockLockPool.h.

41 { }

Member Function Documentation

◆ get_lock()

DataBlockLock* DataBlockLockPool::get_lock ( )
inline

Definition at line 43 of file DataBlockLockPool.h.

References size_.

Referenced by OpenDDS::DCPS::RtpsUdpDataLink::alloc_msgblock(), and OpenDDS::DCPS::TransportSendStrategy::prepare_packet().

43  {
44  const unsigned long index = iterator_++ % size_;
45  return &(pool_[index]);
46  }
OpenDDS::DCPS::Atomic< unsigned long > iterator_
Counter used to track which lock to give out next (modulus size_)
const unsigned long size_

Member Data Documentation

◆ iterator_

OpenDDS::DCPS::Atomic<unsigned long> DataBlockLockPool::iterator_
private

Counter used to track which lock to give out next (modulus size_)

Definition at line 54 of file DataBlockLockPool.h.

◆ pool_

Pool DataBlockLockPool::pool_
private

Definition at line 51 of file DataBlockLockPool.h.

◆ size_

const unsigned long DataBlockLockPool::size_
private

Definition at line 52 of file DataBlockLockPool.h.


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