38 #ifndef PMEMOBJ_POOL_HPP 39 #define PMEMOBJ_POOL_HPP 46 #include "libpmemobj/pool_base.h" 80 explicit pool_base(pmemobjpool *cpop) noexcept : pop(cpop)
122 open(
const std::string &path,
const std::string &layout)
124 pmemobjpool *pop = pmemobj_open(path.c_str(), layout.c_str());
148 create(
const std::string &path,
const std::string &layout,
149 std::size_t size = PMEMOBJ_MIN_POOL,
150 mode_t mode = S_IWUSR | S_IRUSR)
152 pmemobjpool *pop = pmemobj_create(path.c_str(), layout.c_str(),
171 check(
const std::string &path,
const std::string &layout) noexcept
173 return pmemobj_check(path.c_str(), layout.c_str());
184 if (this->pop ==
nullptr)
185 throw std::logic_error(
"Pool already closed");
187 pmemobj_close(this->pop);
198 persist(
const void *addr,
size_t len) noexcept
200 pmemobj_persist(this->pop, addr, len);
208 template <
typename Y>
212 pmemobj_persist(this->pop, &prop,
sizeof(Y));
220 template <
typename Y>
224 pmemobj_persist(this->pop, &ptr,
sizeof(ptr));
234 flush(
const void *addr,
size_t len) noexcept
236 pmemobj_flush(this->pop, addr, len);
244 template <
typename Y>
248 pmemobj_flush(this->pop, &prop,
sizeof(Y));
256 template <
typename Y>
260 pmemobj_flush(this->pop, &ptr,
sizeof(ptr));
269 pmemobj_drain(this->pop);
285 return pmemobj_memcpy_persist(this->pop, dest, src, len);
301 return pmemobj_memset_persist(this->pop, dest, c, len);
312 get_handle() noexcept
330 template <
typename T>
336 pool() noexcept =
default;
341 pool(
const pool &) noexcept =
default;
361 ~
pool() noexcept =
default;
405 open(
const std::string &path,
const std::string &layout)
427 create(
const std::string &path,
const std::string &layout,
428 std::size_t size = PMEMOBJ_MIN_POOL,
429 mode_t mode = S_IWUSR | S_IRUSR)
445 check(
const std::string &path,
const std::string &layout)
Persistent pointer class.
Definition: persistent_ptr.hpp:72
void flush(const p< Y > &prop) noexcept
Performs flush operation on a given pmem property.
Definition: pool.hpp:246
virtual ~pool_base() noexcept=default
Default virtual destructor.
static pool_base create(const std::string &path, const std::string &layout, std::size_t size=PMEMOBJ_MIN_POOL, mode_t mode=S_IWUSR|S_IRUSR)
Creates a new transactional object store pool.
Definition: pool.hpp:148
The non-template pool base class.
Definition: pool.hpp:64
pool(const pool_base &pb) noexcept
Defaulted copy constructor.
Definition: pool.hpp:366
Resides on pmem property template.
pool_base() noexcept
Defaulted constructor.
Definition: pool.hpp:69
void persist(const persistent_ptr< Y > &ptr) noexcept
Performs persist operation on a given persistent object.
Definition: pool.hpp:222
pool(pool_base &&pb) noexcept
Defaulted move constructor.
Definition: pool.hpp:373
void flush(const persistent_ptr< Y > &ptr) noexcept
Performs flush operation on a given persistent object.
Definition: pool.hpp:258
static int check(const std::string &path, const std::string &layout)
Checks if a given pool is consistent.
Definition: pool.hpp:445
PMEMobj pool class.
Definition: persistent_ptr.hpp:55
pool_base & operator=(const pool_base &) noexcept=default
Defaulted copy assignment operator.
void flush(const void *addr, size_t len) noexcept
Performs flush operation on a given chunk of memory.
Definition: pool.hpp:234
static int check(const std::string &path, const std::string &layout) noexcept
Checks if a given pool is consistent.
Definition: pool.hpp:171
void persist(const void *addr, size_t len) noexcept
Performs persist operation on a given chunk of memory.
Definition: pool.hpp:198
void persist(const p< Y > &prop) noexcept
Performs persist operation on a given pmem property.
Definition: pool.hpp:210
persistent_ptr< T > get_root()
Retrieves pool's root object.
Definition: pool.hpp:383
static pool_base open(const std::string &path, const std::string &layout)
Opens an existing object store memory pool.
Definition: pool.hpp:122
Resides on pmem class.
Definition: p.hpp:64
void * memset_persist(void *dest, int c, size_t len) noexcept
Performs memset and persist operation on a given chunk of memory.
Definition: pool.hpp:299
Definition: condition_variable.hpp:48
void drain(void) noexcept
Performs drain operation.
Definition: pool.hpp:267
void close()
Closes the pool.
Definition: pool.hpp:182
pool_base(pmemobjpool *cpop) noexcept
Explicit constructor.
Definition: pool.hpp:80
static pool< T > open(const std::string &path, const std::string &layout)
Opens an existing object store memory pool.
Definition: pool.hpp:405
void * memcpy_persist(void *dest, const void *src, size_t len) noexcept
Performs memcpy and persist operation on a given chunk of memory.
Definition: pool.hpp:283
static pool< T > create(const std::string &path, const std::string &layout, std::size_t size=PMEMOBJ_MIN_POOL, mode_t mode=S_IWUSR|S_IRUSR)
Creates a new transactional object store pool.
Definition: pool.hpp:427
Custom pool error class.
Definition: pexceptions.hpp:53