PMDK C++ bindings
1.8.1
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
49 #include <libpmemobj/pool_base.h>
83 explicit pool_base(pmemobjpool *cpop) noexcept : pop(cpop)
128 pmemobjpool *pop = pmemobj_openU(path.c_str(), layout.c_str());
130 pmemobjpool *pop = pmemobj_open(path.c_str(), layout.c_str());
134 .with_pmemobj_errormsg();
156 create(
const std::string &path,
const std::string &layout,
157 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
160 pmemobjpool *pop = pmemobj_createU(path.c_str(), layout.c_str(),
163 pmemobjpool *pop = pmemobj_create(path.c_str(), layout.c_str(),
168 .with_pmemobj_errormsg();
184 check(
const std::string &path,
const std::string &layout) noexcept
187 return pmemobj_checkU(path.c_str(), layout.c_str());
189 return pmemobj_check(path.c_str(), layout.c_str());
208 open(
const std::wstring &path,
const std::wstring &layout)
210 pmemobjpool *pop = pmemobj_openW(path.c_str(), layout.c_str());
213 .with_pmemobj_errormsg();
236 create(
const std::wstring &path,
const std::wstring &layout,
237 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
239 pmemobjpool *pop = pmemobj_createW(path.c_str(), layout.c_str(),
243 .with_pmemobj_errormsg();
260 check(
const std::wstring &path,
const std::wstring &layout) noexcept
262 return pmemobj_checkW(path.c_str(), layout.c_str());
274 if (this->pop ==
nullptr)
275 throw std::logic_error(
"Pool already closed");
277 pmemobj_close(this->pop);
288 persist(
const void *addr,
size_t len) noexcept
290 pmemobj_persist(this->pop, addr, len);
298 template <
typename Y>
302 pmemobj_persist(this->pop, &prop,
sizeof(Y));
311 template <
typename Y>
315 pmemobj_persist(this->pop, &ptr,
sizeof(ptr));
325 flush(
const void *addr,
size_t len) noexcept
327 pmemobj_flush(this->pop, addr, len);
335 template <
typename Y>
339 pmemobj_flush(this->pop, &prop,
sizeof(Y));
347 template <
typename Y>
351 pmemobj_flush(this->pop, &ptr,
sizeof(ptr));
360 pmemobj_drain(this->pop);
376 return pmemobj_memcpy_persist(this->pop, dest, src, len);
392 return pmemobj_memset_persist(this->pop, dest, c, len);
408 POBJ_CPP_DEPRECATED PMEMobjpool *
409 get_handle() noexcept
420 static const int DEFAULT_MODE = S_IWUSR | S_IRUSR;
423 static const int DEFAULT_MODE = S_IWRITE | S_IREAD;
435 template <
typename T>
492 template <
typename M>
496 return ctl_get_detail<M>(pop, name);
510 template <
typename M>
514 return ctl_set_detail(pop, name, arg);
528 template <
typename M>
532 return ctl_exec_detail(pop, name, arg);
546 template <
typename M>
550 return ctl_get_detail<M>(pop, name);
564 template <
typename M>
568 return ctl_set_detail(pop, name, arg);
582 template <
typename M>
586 return ctl_exec_detail(pop, name, arg);
624 open(
const std::string &path,
const std::string &layout)
646 create(
const std::string &path,
const std::string &layout,
647 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
663 check(
const std::string &path,
const std::string &layout)
683 open(
const std::wstring &path,
const std::wstring &layout)
706 create(
const std::wstring &path,
const std::wstring &layout,
707 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
724 check(
const std::wstring &path,
const std::wstring &layout)
741 template <
typename T>
745 return ctl_get_detail<T>(
nullptr, name);
759 template <
typename T>
763 return ctl_set_detail(
nullptr, name, arg);
777 template <
typename T>
781 return ctl_exec_detail(
nullptr, name, arg);
795 template <
typename T>
799 return ctl_get_detail<T>(
nullptr, name);
813 template <
typename T>
817 return ctl_set_detail(
nullptr, name, arg);
831 template <
typename T>
835 return ctl_exec_detail(
nullptr, name, arg);
T ctl_get(const std::string &name)
Query libpmemobj state at global scope.
Definition: pool.hpp:743
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:374
void persist(const persistent_ptr< Y > &ptr) noexcept
Performs persist operation on a given persistent pointer.
Definition: pool.hpp:313
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:236
M ctl_exec(const std::string &name, M arg)
Execute function at pool scope.
Definition: pool.hpp:530
Custom pool error class.
Definition: pexceptions.hpp:72
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:724
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:646
void persist(const void *addr, size_t len) noexcept
Performs persist operation on a given chunk of memory.
Definition: pool.hpp:288
A persistent version of concurrent hash map implementation Ref: https://arxiv.org/abs/1509....
Definition: allocation_flag.hpp:44
M ctl_get(const std::string &name)
Query libpmemobj state at pool scope.
Definition: pool.hpp:494
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:390
Commonly used functionality.
pool(pool_base &&pb) noexcept
Defaulted move constructor.
Definition: pool.hpp:478
M ctl_get(const std::wstring &name)
Query libpmemobj state at pool scope.
Definition: pool.hpp:548
M ctl_set(const std::wstring &name, M arg)
Modify libpmemobj state at pool scope.
Definition: pool.hpp:566
static int check(const std::string &path, const std::string &layout) noexcept
Checks if a given pool is consistent.
Definition: pool.hpp:184
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:260
void drain(void) noexcept
Performs drain operation.
Definition: pool.hpp:358
void persist(const p< Y > &prop) noexcept
Performs persist operation on a given pmem property.
Definition: pool.hpp:300
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:125
void close()
Closes the pool.
Definition: pool.hpp:272
persistent_ptr< T > root()
Retrieves pool's root object.
Definition: pool.hpp:596
pool_base() noexcept
Defaulted constructor.
Definition: pool.hpp:72
void flush(const persistent_ptr< Y > &ptr) noexcept
Performs flush operation on a given persistent object.
Definition: pool.hpp:349
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:325
PMEMobjpool * handle() noexcept
Gets the C style handle to the pool.
Definition: pool.hpp:403
T ctl_set(const std::string &name, T arg)
Modify libpmemobj state at global scope.
Definition: pool.hpp:761
pool_base(pmemobjpool *cpop) noexcept
Explicit constructor.
Definition: pool.hpp:83
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:156
M ctl_set(const std::string &name, M arg)
Modify libpmemobj state at pool scope.
Definition: pool.hpp:512
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:208
PMEMobj pool class.
Definition: pool.hpp:436
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:624
T ctl_exec(const std::string &name, T arg)
Execute function at global scope.
Definition: pool.hpp:779
M ctl_exec(const std::wstring &name, M arg)
Execute function at pool scope.
Definition: pool.hpp:584
A persistent version of concurrent hash map implementation Ref: https://arxiv.org/abs/1509....
Definition: concurrent_hash_map.hpp:66
void flush(const p< Y > &prop) noexcept
Performs flush operation on a given pmem property.
Definition: pool.hpp:337
static pool< T > open(const std::wstring &path, const std::wstring &layout)
Opens an existing object store memory pool.
Definition: pool.hpp:683
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:706
The non-template pool base class.
Definition: pool.hpp:67
static int check(const std::string &path, const std::string &layout)
Checks if a given pool is consistent.
Definition: pool.hpp:663