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, mode_t mode = DEFAULT_MODE)
151 pmemobjpool *pop = pmemobj_create(path.c_str(), layout.c_str(),
170 check(
const std::string &path,
const std::string &layout) noexcept
172 return pmemobj_check(path.c_str(), layout.c_str());
183 if (this->pop ==
nullptr)
184 throw std::logic_error(
"Pool already closed");
186 pmemobj_close(this->pop);
197 persist(
const void *addr,
size_t len) noexcept
199 pmemobj_persist(this->pop, addr, len);
207 template <
typename Y>
211 pmemobj_persist(this->pop, &prop,
sizeof(Y));
219 template <
typename Y>
223 pmemobj_persist(this->pop, &ptr,
sizeof(ptr));
233 flush(
const void *addr,
size_t len) noexcept
235 pmemobj_flush(this->pop, addr, len);
243 template <
typename Y>
247 pmemobj_flush(this->pop, &prop,
sizeof(Y));
255 template <
typename Y>
259 pmemobj_flush(this->pop, &ptr,
sizeof(ptr));
268 pmemobj_drain(this->pop);
284 return pmemobj_memcpy_persist(this->pop, dest, src, len);
300 return pmemobj_memset_persist(this->pop, dest, c, len);
311 get_handle() noexcept
322 static const int DEFAULT_MODE = S_IWUSR | S_IRUSR;
325 static const int DEFAULT_MODE = S_IWRITE | S_IREAD;
337 template <
typename T>
343 pool() noexcept =
default;
348 pool(
const pool &) noexcept =
default;
368 ~
pool() noexcept =
default;
412 open(
const std::string &path,
const std::string &layout)
434 create(
const std::string &path,
const std::string &layout,
435 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
451 check(
const std::string &path,
const std::string &layout)
static pool< T > create(const std::string &path, const std::string &layout, std::size_t size=PMEMOBJ_MIN_POOL, mode_t mode=DEFAULT_MODE)
Creates a new transactional object store pool.
Definition: pool.hpp:434
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:245
virtual ~pool_base() noexcept=default
Default virtual destructor.
The non-template pool base class.
Definition: pool.hpp:64
pool(const pool_base &pb) noexcept
Defaulted copy constructor.
Definition: pool.hpp:373
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:221
pool(pool_base &&pb) noexcept
Defaulted move constructor.
Definition: pool.hpp:380
void flush(const persistent_ptr< Y > &ptr) noexcept
Performs flush operation on a given persistent object.
Definition: pool.hpp:257
static int check(const std::string &path, const std::string &layout)
Checks if a given pool is consistent.
Definition: pool.hpp:451
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:233
static int check(const std::string &path, const std::string &layout) noexcept
Checks if a given pool is consistent.
Definition: pool.hpp:170
void persist(const void *addr, size_t len) noexcept
Performs persist operation on a given chunk of memory.
Definition: pool.hpp:197
void persist(const p< Y > &prop) noexcept
Performs persist operation on a given pmem property.
Definition: pool.hpp:209
persistent_ptr< T > get_root()
Retrieves pool's root object.
Definition: pool.hpp:390
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:298
Definition: condition_variable.hpp:48
void drain(void) noexcept
Performs drain operation.
Definition: pool.hpp:266
static pool_base create(const std::string &path, const std::string &layout, std::size_t size=PMEMOBJ_MIN_POOL, mode_t mode=DEFAULT_MODE)
Creates a new transactional object store pool.
Definition: pool.hpp:148
void close()
Closes the pool.
Definition: pool.hpp:181
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:412
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:282
Custom pool error class.
Definition: pexceptions.hpp:53