PMDK C++ bindings
1.7
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());
155 create(
const std::string &path,
const std::string &layout,
156 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
159 pmemobjpool *pop = pmemobj_createU(path.c_str(), layout.c_str(),
162 pmemobjpool *pop = pmemobj_create(path.c_str(), layout.c_str(),
182 check(
const std::string &path,
const std::string &layout) noexcept
185 return pmemobj_checkU(path.c_str(), layout.c_str());
187 return pmemobj_check(path.c_str(), layout.c_str());
206 open(
const std::wstring &path,
const std::wstring &layout)
208 pmemobjpool *pop = pmemobj_openW(path.c_str(), layout.c_str());
233 create(
const std::wstring &path,
const std::wstring &layout,
234 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
236 pmemobjpool *pop = pmemobj_createW(path.c_str(), layout.c_str(),
256 check(
const std::wstring &path,
const std::wstring &layout) noexcept
258 return pmemobj_checkW(path.c_str(), layout.c_str());
270 if (this->pop ==
nullptr)
271 throw std::logic_error(
"Pool already closed");
273 pmemobj_close(this->pop);
284 persist(
const void *addr,
size_t len) noexcept
286 pmemobj_persist(this->pop, addr, len);
294 template <
typename Y>
298 pmemobj_persist(this->pop, &prop,
sizeof(Y));
306 template <
typename Y>
310 pmemobj_persist(this->pop, &ptr,
sizeof(ptr));
320 flush(
const void *addr,
size_t len) noexcept
322 pmemobj_flush(this->pop, addr, len);
330 template <
typename Y>
334 pmemobj_flush(this->pop, &prop,
sizeof(Y));
342 template <
typename Y>
346 pmemobj_flush(this->pop, &ptr,
sizeof(ptr));
355 pmemobj_drain(this->pop);
371 return pmemobj_memcpy_persist(this->pop, dest, src, len);
387 return pmemobj_memset_persist(this->pop, dest, c, len);
403 POBJ_CPP_DEPRECATED PMEMobjpool *
404 get_handle() noexcept
415 static const int DEFAULT_MODE = S_IWUSR | S_IRUSR;
418 static const int DEFAULT_MODE = S_IWRITE | S_IREAD;
430 template <
typename T>
487 template <
typename M>
491 return ctl_get_detail<M>(pop, name);
505 template <
typename M>
509 return ctl_set_detail(pop, name, arg);
523 template <
typename M>
527 return ctl_exec_detail(pop, name, arg);
541 template <
typename M>
545 return ctl_get_detail<M>(pop, name);
559 template <
typename M>
563 return ctl_set_detail(pop, name, arg);
577 template <
typename M>
581 return ctl_exec_detail(pop, name, arg);
619 open(
const std::string &path,
const std::string &layout)
641 create(
const std::string &path,
const std::string &layout,
642 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
658 check(
const std::string &path,
const std::string &layout)
678 open(
const std::wstring &path,
const std::wstring &layout)
701 create(
const std::wstring &path,
const std::wstring &layout,
702 std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = DEFAULT_MODE)
719 check(
const std::wstring &path,
const std::wstring &layout)
736 template <
typename T>
740 return ctl_get_detail<T>(
nullptr, name);
754 template <
typename T>
758 return ctl_set_detail(
nullptr, name, arg);
772 template <
typename T>
776 return ctl_exec_detail(
nullptr, name, arg);
790 template <
typename T>
794 return ctl_get_detail<T>(
nullptr, name);
808 template <
typename T>
812 return ctl_set_detail(
nullptr, name, arg);
826 template <
typename T>
830 return ctl_exec_detail(
nullptr, name, arg);
T ctl_get(const std::string &name)
Query libpmemobj state at global scope.
Definition: pool.hpp:738
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:369
void persist(const persistent_ptr< Y > &ptr) noexcept
Performs persist operation on a given persistent object.
Definition: pool.hpp:308
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:233
M ctl_exec(const std::string &name, M arg)
Execute function at pool scope.
Definition: pool.hpp:525
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:719
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:641
void persist(const void *addr, size_t len) noexcept
Performs persist operation on a given chunk of memory.
Definition: pool.hpp:284
M ctl_get(const std::string &name)
Query libpmemobj state at pool scope.
Definition: pool.hpp:489
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:385
Commonly used functionality.
pool(pool_base &&pb) noexcept
Defaulted move constructor.
Definition: pool.hpp:473
M ctl_get(const std::wstring &name)
Query libpmemobj state at pool scope.
Definition: pool.hpp:543
M ctl_set(const std::wstring &name, M arg)
Modify libpmemobj state at pool scope.
Definition: pool.hpp:561
static int check(const std::string &path, const std::string &layout) noexcept
Checks if a given pool is consistent.
Definition: pool.hpp:182
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:256
void drain(void) noexcept
Performs drain operation.
Definition: pool.hpp:353
void persist(const p< Y > &prop) noexcept
Performs persist operation on a given pmem property.
Definition: pool.hpp:296
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:268
persistent_ptr< T > root()
Retrieves pool's root object.
Definition: pool.hpp:591
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:344
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:320
PMEMobjpool * handle() noexcept
Gets the C style handle to the pool.
Definition: pool.hpp:398
T ctl_set(const std::string &name, T arg)
Modify libpmemobj state at global scope.
Definition: pool.hpp:756
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:155
M ctl_set(const std::string &name, M arg)
Modify libpmemobj state at pool scope.
Definition: pool.hpp:507
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:206
PMEMobj pool class.
Definition: pool.hpp:431
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:619
T ctl_exec(const std::string &name, T arg)
Execute function at global scope.
Definition: pool.hpp:774
M ctl_exec(const std::wstring &name, M arg)
Execute function at pool scope.
Definition: pool.hpp:579
A persistent version of concurrent hash map implementation Ref: https://arxiv.org/abs/1509....
Definition: concurrent_hash_map.hpp:75
void flush(const p< Y > &prop) noexcept
Performs flush operation on a given pmem property.
Definition: pool.hpp:332
static pool< T > open(const std::wstring &path, const std::wstring &layout)
Opens an existing object store memory pool.
Definition: pool.hpp:678
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:701
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:658