PMDK C++ bindings  1.13.0-git107.g7e59f08f
This is the C++ bindings documentation for PMDK's libpmemobj.
make_persistent_array_atomic.hpp File Reference

persistent_ptr atomic allocation functions for arrays. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 pmem
 Persistent memory namespace.
 
 pmem::obj
 Main libpmemobj namespace.
 

Functions

template<typename T >
void pmem::obj::make_persistent_atomic (pool_base &pool, typename detail::pp_if_array< T >::type &ptr, std::size_t N, allocation_flag_atomic flag=allocation_flag_atomic::none())
 Atomically allocate an array of objects. More...
 
template<typename T >
void pmem::obj::make_persistent_atomic (pool_base &pool, typename detail::pp_if_size_array< T >::type &ptr, allocation_flag_atomic flag=allocation_flag_atomic::none())
 Atomically allocate an array of objects. More...
 
template<typename T >
void pmem::obj::delete_persistent_atomic (typename detail::pp_if_array< T >::type &ptr, std::size_t)
 Atomically deallocate an array of objects. More...
 
template<typename T >
void pmem::obj::delete_persistent_atomic (typename detail::pp_if_size_array< T >::type &ptr)
 Atomically deallocate an array of objects. More...
 

Detailed Description

persistent_ptr atomic allocation functions for arrays.

The typical usage examples would be:

#include <fcntl.h>
using namespace pmem::obj;
void
make_persistent_array_atomic_example()
{
struct compound_type {
compound_type() : some_variable(0), some_other_variable(0)
{
}
void
set_some_variable(int val)
{
some_variable = val;
}
p<int> some_variable;
p<double> some_other_variable;
};
/* pool root structure */
struct root {
persistent_ptr<compound_type[]> comp;
};
/* create a pmemobj pool */
auto pop = pool<root>::create("poolfile", "layout", PMEMOBJ_MIN_POOL);
auto proot = pop.root();
/* typical usage schemes */
/* atomic array allocation and construction - the compound_type has to
* be default constructible */
make_persistent_atomic<compound_type[]>(pop, proot->comp, 20);
persistent_ptr<compound_type[42]> arr;
make_persistent_atomic<compound_type[42]>(pop, arr);
/* atomic array deallocation, no destructor being called */
delete_persistent_atomic<compound_type[]>(proot->comp, 20);
delete_persistent_atomic<compound_type[42]>(arr);
/* error prone cases */
transaction::run(pop, [&] {
/* possible invalid state in case of transaction abort */
make_persistent_atomic<compound_type[]>(pop, proot->comp, 30);
delete_persistent_atomic<compound_type[]>(proot->comp, 30);
});
}
static void run(obj::pool_base &pool, std::function< void()> tx, Locks &... locks)
Execute a closure-like transaction and lock locks.
Definition: transaction.hpp:676
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
persistent_ptr atomic allocation functions for arrays.
Main libpmemobj namespace.
Definition: allocation_flag.hpp:18
Resides on pmem property template.
Persistent smart pointer.
C++ pmemobj pool.
C++ pmemobj transactions.