Resides on pmem class.
More...
#include <libpmemobj++/p.hpp>
|
| p (const T &_val) noexcept |
| Value constructor. More...
|
|
| p ()=default |
| Defaulted constructor.
|
|
p & | operator= (const p &rhs) |
| Assignment operator. More...
|
|
template<typename Y , typename = typename std::enable_if< std::is_convertible<Y, T>::value>::type> |
p & | operator= (const p< Y > &rhs) |
| Converting assignment operator from a different p<>. More...
|
|
| operator T () const noexcept |
| Conversion operator back to the underlying type.
|
|
T & | get_rw () |
| Retrieves read-write reference of the object. More...
|
|
const T & | get_ro () const noexcept |
| Retrieves read-only const reference of the object. More...
|
|
void | swap (p &other) |
| Swaps two p objects of the same type. More...
|
|
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 {
} proot;
proot.counter = 12;
proot.whoops.get_rw().set_some_variable(2);
proot.whoops.get_rw().some_other_variable = 3.0;
});
proot.counter = 12;
}
◆ p()
Value constructor.
Directly assigns a value to the underlying storage.
- Parameters
-
_val | const reference to the value to be assigned. |
◆ get_ro()
Retrieves read-only const reference of the object.
This method has no transaction side effects.
- Returns
- a const reference to the object.
◆ get_rw()
Retrieves read-write reference of the object.
The entire object is automatically added to the transaction.
- Returns
- a reference to the object.
- Exceptions
-
◆ operator=() [1/2]
Assignment operator.
The p<> class property assignment within a transaction automatically registers this operation so that a rollback is possible.
- Exceptions
-
◆ operator=() [2/2]
template<typename T>
template<typename Y , typename = typename std::enable_if< std::is_convertible<Y, T>::value>::type>
Converting assignment operator from a different p<>.
Available only for convertible types. Just like regular assignment, also automatically registers itself in a transaction.
- Exceptions
-
◆ swap()
Swaps two p objects of the same type.
- Exceptions
-
The documentation for this class was generated from the following file:
- pmdk-1.4.2/src/include/libpmemobj++/p.hpp