138
124
assert(pvector == stdvector); /* pvector element's value was
rolled back */
125
126
try {
127
pmem::obj::delete_persistent(&pvector);
128
} catch (std::exception &e) {
129
}
If an active transaction exists, elements accessed using any of the preceding methods
are snapshotted. When iterators are returned by begin() and end(), snapshotting
happens during the iterator dereferencing phase. Note that snapshotting is done only
for mutable elements. In the case of constant iterators or constant versions of indexing
operator, nothing is added to the transaction. That is why it is essential to use const
qualified function overloads such as cbegin() or cend() whenever possible. If an object
snapshot occurs in the current transaction, a second snapshot of the same memory
address will not be performed and thus will not have performance overhead. This will
reduce the number of snapshots and can significantly reduce the performance impact
of transactions. Note also that pmem::obj::vector does define convenient constructors
and compare operators that take std::vector as an argument.
Summary
This chapter describes the libpmemobj-cpp library. It makes creating applications less
error prone, and its similarity to standard C++ API makes it easier to modify existing
volatile programs to use persistent memory. We also list the limitations of this library
and the problems you must consider during development.
Chapter 8 libpmemobj-Cpp: the adaptable language - C++ and persistent memory
Précédent

- 164/457

Suivant