PMDK C++ bindings
1.5.2
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Go to the documentation of this file.
38 #ifndef LIBPMEMOBJ_CPP_POOL_HPP
39 #define LIBPMEMOBJ_CPP_POOL_HPP
48 #include <libpmemobj/pool_base.h>
82 explicit pool_base(pmemobjpool *cpop) noexcept : pop(cpop)
124 open(const std::
string &path, const std::
string &layout)
127 pmemobjpool *pop = pmemobj_openU(path.c_str(), layout.c_str());
129 pmemobjpool *pop = pmemobj_open(path.c_str(), layout.c_str());
154 create(
const std::string &path,
const std::string &layout,
155 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
158 pmemobjpool *pop = pmemobj_createU(path.c_str(), layout.c_str(),
161 pmemobjpool *pop = pmemobj_create(path.c_str(), layout.c_str(),
181 check(
const std::string &path,
const std::string &layout) noexcept
184 return pmemobj_checkU(path.c_str(), layout.c_str());
186 return pmemobj_check(path.c_str(), layout.c_str());
205 open(
const std::wstring &path,
const std::wstring &layout)
207 pmemobjpool *pop = pmemobj_openW(path.c_str(), layout.c_str());
232 create(
const std::wstring &path,
const std::wstring &layout,
233 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
235 pmemobjpool *pop = pmemobj_createW(path.c_str(), layout.c_str(),
255 check(
const std::wstring &path,
const std::wstring &layout) noexcept
257 return pmemobj_checkW(path.c_str(), layout.c_str());
269 if (this->pop ==
nullptr)
270 throw std::logic_error(
"Pool already closed");
272 pmemobj_close(this->pop);
283 persist(
const void *addr,
size_t len) noexcept
285 pmemobj_persist(this->pop, addr, len);
293 template <
typename Y>
297 pmemobj_persist(this->pop, &prop,
sizeof(Y));
305 template <
typename Y>
309 pmemobj_persist(this->pop, &ptr,
sizeof(ptr));
319 flush(
const void *addr,
size_t len) noexcept
321 pmemobj_flush(this->pop, addr, len);
329 template <
typename Y>
333 pmemobj_flush(this->pop, &prop,
sizeof(Y));
341 template <
typename Y>
345 pmemobj_flush(this->pop, &ptr,
sizeof(ptr));
354 pmemobj_drain(this->pop);
370 return pmemobj_memcpy_persist(this->pop, dest, src, len);
386 return pmemobj_memset_persist(this->pop, dest, c, len);
402 POBJ_CPP_DEPRECATED PMEMobjpool *
403 get_handle() noexcept
405 return pool_base::handle();
414 static const int DEFAULT_MODE = S_IWUSR | S_IRUSR;
417 static const int DEFAULT_MODE = S_IWRITE | S_IREAD;
429 template <
typename T>
510 open(
const std::string &path,
const std::string &layout)
532 create(
const std::string &path,
const std::string &layout,
533 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
549 check(
const std::string &path,
const std::string &layout)
569 open(
const std::wstring &path,
const std::wstring &layout)
592 create(
const std::wstring &path,
const std::wstring &layout,
593 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
610 check(
const std::wstring &path,
const std::wstring &layout)
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:368
void persist(const persistent_ptr< Y > &ptr) noexcept
Performs persist operation on a given persistent object.
Definition: pool.hpp:307
static pool_base create(const std::wstring &path, const std::wstring &layout, std::size_t size=PMEMOBJ_MIN_POOL, mode_t mode=DEFAULT_MODE)
Creates a new transactional object store pool.
Definition: pool.hpp:232
Custom pool error class.
Definition: pexceptions.hpp:53
pool_base(const pool_base &) noexcept=default
Defaulted copy constructor.
static int check(const std::wstring &path, const std::wstring &layout)
Checks if a given pool is consistent.
Definition: pool.hpp:610
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:532
void persist(const void *addr, size_t len) noexcept
Performs persist operation on a given chunk of memory.
Definition: pool.hpp:283
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:384
Commonly used functionality.
pool(pool_base &&pb) noexcept
Defaulted move constructor.
Definition: pool.hpp:472
static int check(const std::string &path, const std::string &layout) noexcept
Checks if a given pool is consistent.
Definition: pool.hpp:181
pool_base(pool_base &&) noexcept=default
Defaulted move constructor.
static int check(const std::wstring &path, const std::wstring &layout) noexcept
Checks if a given pool is consistent.
Definition: pool.hpp:255
void drain(void) noexcept
Performs drain operation.
Definition: pool.hpp:352
void persist(const p< Y > &prop) noexcept
Performs persist operation on a given pmem property.
Definition: pool.hpp:295
Resides on pmem class.
Definition: p.hpp:64
static pool_base open(const std::string &path, const std::string &layout)
Opens an existing object store memory pool.
Definition: pool.hpp:124
void close()
Closes the pool.
Definition: pool.hpp:267
persistent_ptr< T > root()
Retrieves pool's root object.
Definition: pool.hpp:482
pool_base() noexcept
Defaulted constructor.
Definition: pool.hpp:71
void flush(const persistent_ptr< Y > &ptr) noexcept
Performs flush operation on a given persistent object.
Definition: pool.hpp:343
pool() noexcept=default
Defaulted constructor.
void flush(const void *addr, size_t len) noexcept
Performs flush operation on a given chunk of memory.
Definition: pool.hpp:319
pool_base(pmemobjpool *cpop) noexcept
Explicit constructor.
Definition: pool.hpp:82
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:154
Persistent pointer class.
Definition: persistent_ptr.hpp:132
static pool_base open(const std::wstring &path, const std::wstring &layout)
Opens an existing object store memory pool.
Definition: pool.hpp:205
PMEMobj pool class.
Definition: pool.hpp:430
Resides on pmem property template.
static pool< T > open(const std::string &path, const std::string &layout)
Opens an existing object store memory pool.
Definition: pool.hpp:510
void flush(const p< Y > &prop) noexcept
Performs flush operation on a given pmem property.
Definition: pool.hpp:331
static pool< T > open(const std::wstring &path, const std::wstring &layout)
Opens an existing object store memory pool.
Definition: pool.hpp:569
static pool< T > create(const std::wstring &path, const std::wstring &layout, std::size_t size=PMEMOBJ_MIN_POOL, mode_t mode=DEFAULT_MODE)
Creates a new transactional object store pool.
Definition: pool.hpp:592
The non-template pool base class.
Definition: pool.hpp:66
static int check(const std::string &path, const std::string &layout)
Checks if a given pool is consistent.
Definition: pool.hpp:549