|
LSSTApplications
8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
|
A thread-safe memory block allocator that uses a Bitset to track which blocks (out of a fixed size pool of blocks) are in-use/free. More...
#include <ChunkManagerImpl.h>
Public Member Functions | |
| BlockAllocator (unsigned char const *const ref, std::size_t const offset) | |
| std::size_t | allocate () |
| void | allocate (std::size_t *const blockOffsets, int const n) |
| void | free (std::size_t const *const blockOffsets, int const n) |
Private Types | |
| typedef Bitset < boost::uint64_t, TraitsT::NUM_BLOCKS > | Allocator |
Private Member Functions | |
| BOOST_STATIC_ASSERT (TraitsT::ENTRIES_PER_BLOCK_LOG2 >=9) | |
Private Attributes | |
| MutexT | _mutex |
| Allocator | _allocator |
| std::size_t const | _offset |
Static Private Attributes | |
| static std::size_t const | BLOCK_SIZE |
A thread-safe memory block allocator that uses a Bitset to track which blocks (out of a fixed size pool of blocks) are in-use/free.
The allocator never returns raw pointers - instead, blocks are identified by an offset in bytes relative to the address of the allocator instance.
This scheme allows an allocator instance, the memory blocks it manages, and offsets referencing them to be stored in shared memory. Clients then map these offsets to an actual block address simply by adding the offsets to the (process-specific) block allocator address.
Definition at line 149 of file ChunkManagerImpl.h.
|
private |
Definition at line 158 of file ChunkManagerImpl.h.
| lsst::ap::detail::BlockAllocator< MutexT, DataT, TraitsT >::BlockAllocator | ( | unsigned char const *const | reference, |
| std::size_t const | offset | ||
| ) |
Creates a new BlockAllocator instance. The memory blocks to be tracked by the allocator are located in contiguous memory, starting offset bytes after the given reference address.
| [in] | reference | The address relative to which offset is specified. |
| [in] | offset | The location of the first memory block in the pool of contiguous blocks to be managed by this allocator instance, specified as an offset in bytes relative to the reference address. |
Definition at line 252 of file ChunkManagerImpl.cc.
| std::size_t lsst::ap::detail::BlockAllocator< MutexT, DataT, TraitsT >::allocate | ( | ) |
Allocates a single memory block.
| lsst::pex::exceptions:::MemoryError | Thrown if there was no free block available. |
Definition at line 274 of file ChunkManagerImpl.cc.
| void lsst::ap::detail::BlockAllocator< MutexT, DataT, TraitsT >::allocate | ( | std::size_t *const | blockOffsets, |
| int const | n | ||
| ) |
Allocates n memory blocks, storing their offsets in the given array.
| [out] | blockOffsets | The array in which the offsets (relative to this allocator instance) of allocated memory blocks are stored. Assumed to be of length at least n. |
| [in] | n | The number of memory blocks to allocate. |
| lsst::pex::exceptions:::MemoryError | Thrown if there were less than n free blocks available. |
| lsst::pex::exceptions:::RangeError | Thrown if the number of blocks to allocate is negative or too large. |
Definition at line 297 of file ChunkManagerImpl.cc.
|
private |
| void lsst::ap::detail::BlockAllocator< MutexT, DataT, TraitsT >::free | ( | std::size_t const *const | blockOffsets, |
| int const | n | ||
| ) |
Frees n memory blocks, identified by offsets stored in the given array. Never throws.
| [in] | blockOffsets | The array in which the offsets (relative to this allocator instance) of the memory blocks to free are stored. Assumed to be of length at least n. |
| [in] | n | The number of memory blocks to free. |
Definition at line 327 of file ChunkManagerImpl.cc.
|
private |
Definition at line 166 of file ChunkManagerImpl.h.
|
private |
Definition at line 165 of file ChunkManagerImpl.h.
|
private |
Definition at line 167 of file ChunkManagerImpl.h.
|
staticprivate |
Definition at line 162 of file ChunkManagerImpl.h.
1.8.5