pageIndex(PageIndexId(id), capacity),
shm(id.termedBuf())
{
- shm.create(sizeof(Shared) + pageSize*capacity);
+ shm.create(Shared::MemSize(capacity, pageSize));
assert(shm.mem());
shared = new (shm.mem()) Shared(capacity, pageSize);
}
if (LastPagePoolId + 1 == 0)
++LastPagePoolId; // skip zero pool id
}
+
+off_t
+Ipc::Mem::PagePool::Shared::MemSize(const unsigned int capacity, const size_t pageSize)
+{
+ return static_cast<off_t>(sizeof(Shared)) +
+ static_cast<off_t>(pageSize) * capacity;
+}
struct Shared {
Shared(const unsigned int aCapacity, const size_t aPageSize);
+ /// total shared memory size required to share
+ static off_t MemSize(const unsigned int capacity, const size_t pageSize);
+
const unsigned int theId; ///< pool id
const unsigned int theCapacity; ///< number of pages in the pool
const size_t thePageSize; ///< page size
PageStack pageIndex; ///< free pages index
Segment shm; ///< shared memory segment to store metadata (and pages)
- Shared *shared; ///< our metadata and page storage, shared among all stack users
+ Shared *shared; ///< our metadata and page storage, shared among all pool users
};
} // namespace Mem