Defrag class.
This class implements methods used to store pointers from a pool. When defragmentation is called/run, all objects previously stored will be a subject of a defragmentation process.
#include <iostream>
#include <libpmemobj/atomic_base.h>
struct root {
};
void
{
r->i = make_persistent<int>(5);
r->v = make_persistent<vector<int>>();
r->v2 = make_persistent<vector<double>>();
i_ptr = make_persistent<int>(10);
});
r->v->push_back(15);
my_defrag.add(r->i);
my_defrag.add(r->v);
my_defrag.add(*r->v2);
my_defrag.add(i_ptr);
std::cout << is_defragmentable<persistent_ptr<int>>();
static_assert(is_defragmentable<vector<char>>(), "should not assert");
pobj_defrag_result result;
try {
result = my_defrag.run();
std::cerr << e.what() << "No. of the relocated objects: "
<<
" out of total: " << e.
result.total
<< " processed." << std::endl;
}
std::cout << "No. of relocated objects: " << result.relocated
<< " out of total: " << result.total << " processed."
<< std::endl;
}
Custom defrag error class.
Definition: pexceptions.hpp:225
pobj_defrag_result result
Results of the defragmentation run.
Definition: pexceptions.hpp:249
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
Defrag class.
Definition: defrag.hpp:83
Persistent pointer class.
Definition: persistent_ptr.hpp:152
PMEMobj pool class.
Definition: pool.hpp:482
persistent_ptr< T > root()
Retrieves pool's root object.
Definition: pool.hpp:644
Main libpmemobj namespace.
Definition: allocation_flag.hpp:18
Base class for persistent_ptr.
Vector container with std::vector compatible interface.