template<typename T>
class pmem::obj::p< T >
Resides on pmem class.
p class is a property-like template class that has to be used for all variables (excluding persistent pointers), which are used in pmemobj transactions. The p property makes sure that changes to a variable within a transaction are made atomically with respect to persistence. It does it by creating a snapshot of the variable when modified in the transaction scope. The p class is not designed to be used with compound types. For that see the persistent_ptr.
#include <fcntl.h>
void
p_property_example()
{
struct compound_type {
void
set_some_variable(int val)
{
some_variable = val;
}
int some_variable;
double some_other_variable;
};
static struct root {
p<int> counter;
p<compound_type> whoops;
} proot;
proot.counter = 12;
proot.whoops.get_rw().set_some_variable(2);
proot.whoops.get_rw().some_other_variable = 3.0;
});
proot.counter = 12;
}
static void run(obj::pool_base &pool, std::function< void()> tx, Locks &... locks)
Execute a closure-like transaction and lock locks.
Definition: transaction.hpp:694
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:694
Main libpmemobj namespace.
Definition: allocation_flag.hpp:18
Resides on pmem property template.
C++ pmemobj transactions.