pmem::obj::pool< T > Class Template Reference

PMEMobj pool class. More...

`#include <libpmemobj++/pool.hpp>`

Inheritance diagram for pmem::obj::pool< T >:
[legend]
Collaboration diagram for pmem::obj::pool< T >:
[legend]

## Public Member Functions

| pool () noexcept=default
| Defaulted constructor.
| pool (const pool &) noexcept=default
| Defaulted copy constructor.
| pool (pool &&) noexcept=default
| Defaulted move constructor.
pool & | operator= (const pool &) noexcept=default
| Defaulted copy assignment operator.
pool & | operator= (pool &&) noexcept=default
| Defaulted move assignment operator.
| ~pool () noexcept=default
| Default destructor.
| pool (const pool_base &pb) noexcept
| Defaulted copy constructor.
| pool (pool_base &&pb) noexcept
| Defaulted move constructor.
persistent_ptr< T > | get_root ()
| Retrieves pool's root object. More...
Public Member Functions inherited from pmem::obj::pool_base
| pool_base () noexcept
| Defaulted constructor.
| pool_base (pmemobjpool *cpop) noexcept
| Explicit constructor. More...
| pool_base (const pool_base &) noexcept=default
| Defaulted copy constructor.
| pool_base (pool_base &&) noexcept=default
| Defaulted move constructor.
pool_base & | operator= (const pool_base &) noexcept=default
| Defaulted copy assignment operator.
pool_base & | operator= (pool_base &&) noexcept=default
| Defaulted move assignment operator.
virtual | ~pool_base () noexcept=default
| Default virtual destructor.
void | close ()
| Closes the pool. More...
void | persist (const void *addr, size_t len) noexcept
| Performs persist operation on a given chunk of memory. More...
template<typename Y >
void | persist (const p< Y > &prop) noexcept
| Performs persist operation on a given pmem property. More...
template<typename Y >
void | persist (const persistent_ptr< Y > &ptr) noexcept
| Performs persist operation on a given persistent object. More...
void | flush (const void *addr, size_t len) noexcept
| Performs flush operation on a given chunk of memory. More...
template<typename Y >
void | flush (const p< Y > &prop) noexcept
| Performs flush operation on a given pmem property. More...
template<typename Y >
void | flush (const persistent_ptr< Y > &ptr) noexcept
| Performs flush operation on a given persistent object. More...
void | drain (void) noexcept
| Performs drain operation.
void * | memcpy_persist (void *dest, const void *src, size_t len) noexcept
| Performs memcpy and persist operation on a given chunk of memory. More...
void * | memset_persist (void *dest, int c, size_t len) noexcept
| Performs memset and persist operation on a given chunk of memory. More...

## Static Public Member Functions

static pool< T > | open (const std::string &path, const std::string &layout)
| Opens an existing object store memory pool. More...
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. More...
static int | check (const std::string &path, const std::string &layout)
| Checks if a given pool is consistent. More...
static pool< T > | open (const std::wstring &path, const std::wstring &layout)
| Opens an existing object store memory pool. More...
static pool< T > | create (const std::wstring &path, const std::wstring &layout, std::size_t size=PMEMOBJ_MIN_POOL, mode_t mode=DEFAULT_MODE)
| Creates a new transactional object store pool. More...
static int | check (const std::wstring &path, const std::wstring &layout)
| Checks if a given pool is consistent. More...
Static Public Member Functions inherited from pmem::obj::pool_base
static pool_base | open (const std::string &path, const std::string &layout)
| Opens an existing object store memory pool. More...
static pool_base | 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. More...
static int | check (const std::string &path, const std::string &layout) noexcept
| Checks if a given pool is consistent. More...
static pool_base | open (const std::wstring &path, const std::wstring &layout)
| Opens an existing object store memory pool. More...
static pool_base | create (const std::wstring &path, const std::wstring &layout, std::size_t size=PMEMOBJ_MIN_POOL, mode_t mode=DEFAULT_MODE)
| Creates a new transactional object store pool. More...
static int | check (const std::wstring &path, const std::wstring &layout) noexcept
| Checks if a given pool is consistent. More...

## Detailed Description

### template<typename T>
class pmem::obj::pool< T >

PMEMobj pool class.

This class is the pmemobj pool handler. It provides basic primitives for operations on pmemobj pools. The template parameter defines the type of the root object within the pool. The typical usage example would be:

#include <fcntl.h>
#include <libpmemobj++/p.hpp>
#include <libpmemobj++/persistent_ptr.hpp>
#include <libpmemobj++/pool.hpp>
using namespace pmem::obj;
void
pool_example()
{
// pool root structure
struct root {
p<int> some_array[42];
p<int> some_other_array[42];
p<double> some_variable;
};
// create a pmemobj pool
auto pop = pool<root>::create("poolfile", "layout", PMEMOBJ_MIN_POOL);
// close a pmemobj pool
pop.close();
// or open a pmemobj pool
pop = pool<root>::open("poolfile", "layout");
// typical usage schemes
auto root_obj = pop.get_root();
// low-level memory manipulation
root_obj->some_variable = 3.2;
pop.persist(root_obj->some_variable);
pop.memset_persist(root_obj->some_array, 2,
sizeof(root_obj->some_array));
pop.memcpy_persist(root_obj->some_other_array, root_obj->some_array,
sizeof(root_obj->some_array));
pop.close();
// check pool consistency
pool<root>::check("poolfile", "layout");
}

## Member Function Documentation

## check() [1/2]

template<typename T >

static int pmem::obj::pool< T >::check | ( | const std::string & | path,
|  | const std::string & | layout
| ) |  |

inline static

Checks if a given pool is consistent.

Parameters

  path | System path to the file containing the memory pool or a pool set.
  layout | Unique identifier of the pool as specified at pool creation time.

Returns
  -1 on error, 1 if file is consistent, 0 otherwise.

## check() [2/2]

template<typename T >

static int pmem::obj::pool< T >::check | ( | const std::wstring & | path,
|  | const std::wstring & | layout
| ) |  |

inline static

Checks if a given pool is consistent.

Wide string variant. Available only on Windows.

Parameters

  path | System path to the file containing the memory pool or a pool set.
  layout | Unique identifier of the pool as specified at pool creation time.

Returns
  -1 on error, 1 if file is consistent, 0 otherwise.

## create() [1/2]

template<typename T >

static pool<T> pmem::obj::pool< T >::create | ( | const std::string & | path,
|  | const std::string & | layout,
|  | std::size_t | size = `PMEMOBJ_MIN_POOL`,
|  | mode_t | mode = `DEFAULT_MODE`
| ) |  |

inline static

Creates a new transactional object store pool.

Parameters

  path | System path to the file to be created. If exists the pool can be created in-place depending on the size parameter. Existing file must be zeroed.
  layout | Unique identifier of the pool, can be a null-terminated string.
  size | Size of the pool in bytes. If zero and the file exists the pool is created in-place.
  mode | File mode for the new file.

Returns
  handle to the created pool.

Exceptions

  pmem::pool_error | when an error during creation occurs.

## create() [2/2]

template<typename T >

static pool<T> pmem::obj::pool< T >::create | ( | const std::wstring & | path,
|  | const std::wstring & | layout,
|  | std::size_t | size = `PMEMOBJ_MIN_POOL`,
|  | mode_t | mode = `DEFAULT_MODE`
| ) |  |

inline static

Creates a new transactional object store pool.

Wide string variant. Available only on Windows.

Parameters

  path | System path to the file to be created. If exists the pool can be created in-place depending on the size parameter. Existing file must be zeroed.
  layout | Unique identifier of the pool, can be a null-terminated string.
  size | Size of the pool in bytes. If zero and the file exists the pool is created in-place.
  mode | File mode for the new file.

Returns
  handle to the created pool.

Exceptions

  pmem::pool_error | when an error during creation occurs.

## get_root()

template<typename T >

persistent_ptr<T> pmem::obj::pool< T >::get_root | ( |  | ) |

inline

Retrieves pool's root object.

Returns
  persistent pointer to the root object.

## open() [1/2]

template<typename T >

static pool<T> pmem::obj::pool< T >::open | ( | const std::string & | path,
|  | const std::string & | layout
| ) |  |

inline static

Opens an existing object store memory pool.

Parameters

  path | System path to the file containing the memory pool or a pool set.
  layout | Unique identifier of the pool as specified at pool creation time.

Returns
  handle to the opened pool.

Exceptions

  pmem::pool_error | when an error during opening occurs.

## open() [2/2]

template<typename T >

static pool<T> pmem::obj::pool< T >::open | ( | const std::wstring & | path,
|  | const std::wstring & | layout
| ) |  |

inline static

Opens an existing object store memory pool.

Wide string variant. Available only on Windows.

Parameters

  path | System path to the file containing the memory pool or a pool set.
  layout | Unique identifier of the pool as specified at pool creation time.

Returns
  handle to the opened pool.

Exceptions

  pmem::pool_error | when an error during opening occurs.

The documentation for this class was generated from the following files:

- pmdk-1.4.1/src/include/libpmemobj++/persistent_ptr.hpp
- pmdk-1.4.1/src/include/libpmemobj++/pool.hpp