|
| pool_base () noexcept |
| Defaulted constructor.
|
|
| pool_base (pmemobjpool *cpop) noexcept |
| Explicit constructor. More...
|
|
| pool_base (const pool_base &) noexcept=default |
| Defaulted copy constructor.
|
|
| pool_base (pool_base &&) noexcept=default |
| Defaulted move constructor.
|
|
pool_base & | operator= (const pool_base &) noexcept=default |
| Defaulted copy assignment operator.
|
|
pool_base & | operator= (pool_base &&) noexcept=default |
| Defaulted move assignment operator.
|
|
virtual | ~pool_base () noexcept=default |
| Default virtual destructor.
|
|
void | close () |
| Closes the pool. More...
|
|
void | persist (const void *addr, size_t len) noexcept |
| Performs persist operation on a given chunk of memory. More...
|
|
template<typename Y > |
void | persist (const p< Y > &prop) noexcept |
| Performs persist operation on a given pmem property. More...
|
|
template<typename Y > |
void | persist (const persistent_ptr< Y > &ptr) noexcept |
| Performs persist operation on a given persistent pointer. More...
|
|
void | flush (const void *addr, size_t len) noexcept |
| Performs flush operation on a given chunk of memory. More...
|
|
template<typename Y > |
void | flush (const p< Y > &prop) noexcept |
| Performs flush operation on a given pmem property. More...
|
|
template<typename Y > |
void | flush (const persistent_ptr< Y > &ptr) noexcept |
| Performs flush operation on a given persistent object. More...
|
|
void | drain (void) noexcept |
| Performs drain operation.
|
|
void * | memcpy_persist (void *dest, const void *src, size_t len) noexcept |
| Performs memcpy and persist operation on a given chunk of memory. More...
|
|
void * | memset_persist (void *dest, int c, size_t len) noexcept |
| Performs memset and persist operation on a given chunk of memory. More...
|
|
PMEMobjpool * | handle () noexcept |
| Gets the C style handle to the pool. More...
|
|
POBJ_CPP_DEPRECATED PMEMobjpool * | get_handle () noexcept |
|
pobj_defrag_result | defrag (persistent_ptr_base **ptrv, size_t oidcnt) |
| Starts defragmentation using selected pointers within this pool. More...
|
|
|
static pool_base | open (const std::string &path, const std::string &layout) |
| Opens an existing object store memory pool. More...
|
|
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. More...
|
|
static int | check (const std::string &path, const std::string &layout) noexcept |
| Checks if a given pool is consistent. More...
|
|
static pool_base | open (const std::wstring &path, const std::wstring &layout) |
| Opens an existing object store memory pool. More...
|
|
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. More...
|
|
static int | check (const std::wstring &path, const std::wstring &layout) noexcept |
| Checks if a given pool is consistent. More...
|
|
The non-template pool base class.
This class is a non-template version of pool. It is useful for places where providing pool template argument is undesirable. The typical usage example would be:
#include <fcntl.h>
void
pool_base_example()
{
struct some_struct {
p<int> some_array[42];
p<int> some_other_array[42];
p<int> some_variable;
};
pop.close();
persistent_ptr<some_struct> pval;
make_persistent_atomic<some_struct>(pop, pval);
pval->some_variable = 3;
pop.persist(pval->some_variable);
pop.memset_persist(pval->some_array, 2, sizeof(pval->some_array));
pop.memcpy_persist(pval->some_other_array, pval->some_array,
sizeof(pval->some_array));
pop.close();
}
static pool_base open(const std::string &path, const std::string &layout)
Opens an existing object store memory pool.
Definition: pool.hpp:109
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:140
static int check(const std::string &path, const std::string &layout) noexcept
Checks if a given pool is consistent.
Definition: pool.hpp:168
persistent_ptr atomic allocation functions for objects.
Main libpmemobj namespace.
Definition: allocation_flag.hpp:18
Resides on pmem property template.
The example of using pool with RAII idiom:
class Foo {
private:
struct persistent_data {
p<int> some_variable;
};
pool_type pop;
const char *layout = "pool_layout";
public:
Foo(const char *poolfile_path)
{
if (pool_type::check(poolfile_path, layout) == 1) {
pop = pool_type::open(poolfile_path, layout);
} else {
std::cerr << "Cannot open pool" << std::endl
<< "Trying to create a new one " << std::endl;
pop = pool_type::create("poolfile", layout,
PMEMOBJ_MIN_POOL);
}
}
Foo() = delete;
~Foo()
{
try {
pop.close();
} catch (...) {
}
}
void
set(int variable)
{
auto root_obj = pop.root();
root_obj->some_variable = variable;
pop.persist(root_obj->some_variable);
}
void
increment()
{
set(pop.root()->some_variable + 1);
}
void
print()
{
std::cout << pop.root()->some_variable << std::endl;
}
};
void
pool_example()
{
auto foo = Foo("poolfile");
foo.print();
foo.set(42);
foo.print();
foo.increment();
foo.print();
}
PMEMobj pool class.
Definition: pool.hpp:482
Persistent smart pointer.