inline pool_base pool_by_pptr(const persistent_ptr<T> ptr) { auto pop = pmemobj_pool_by_oid(ptr.raw()); if (!pop) throw pool_error("Object not in an open pool."); return pool_base(pop); }
/** * Opens an existing object store memory pool. * * @param path System path to the file containing the memory * pool or a pool set. * @param layout Unique identifier of the pool as specified at * pool creation time. * * @return handle to the opened pool. * * @throw nvml::pool_error when an error during opening occurs. */ static pool_base open(const std::string &path, const std::string &layout) { pmemobjpool *pop = pmemobj_open(path.c_str(), layout.c_str()); if (pop == nullptr) throw pool_error("Failed opening pool"); return pool_base(pop); }
inline pool_base pool_by_vptr(const T *that) { auto pop = pmemobj_pool_by_ptr(that); if (!pop) throw pool_error("Object not in an open pool."); return pool_base(pop); }
/** * Creates a new transactional object store pool. * * @param 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. * @param layout Unique identifier of the pool, can be a * NULL-terminated string. * @param size Size of the pool in bytes. If zero and the file * exists the pool is created in-place. * @param mode File mode for the new file. * * @return handle to the created pool. * * @throw nvml::pool_error when an error during creation occurs. */ static pool_base create(const std::string &path, const std::string &layout, std::size_t size = PMEMOBJ_MIN_POOL, mode_t mode = S_IWUSR | S_IRUSR) { pmemobjpool *pop = pmemobj_create(path.c_str(), layout.c_str(), size, mode); if (pop == nullptr) throw pool_error("Failed creating pool"); return pool_base(pop); }