本文整理汇总了C++中PMEMobjpool::memcpy_persist_local方法的典型用法代码示例。如果您正苦于以下问题:C++ PMEMobjpool::memcpy_persist_local方法的具体用法?C++ PMEMobjpool::memcpy_persist_local怎么用?C++ PMEMobjpool::memcpy_persist_local使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMEMobjpool
的用法示例。
在下文中一共展示了PMEMobjpool::memcpy_persist_local方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*
* obj_rep_persist -- (internal) persist with replication
*/
static void
obj_rep_persist(PMEMobjpool *pop, void *addr, size_t len)
{
LOG(15, "pop %p addr %p len %zu", pop, addr, len);
PMEMobjpool *rep = pop->replica;
while (rep) {
void *raddr = (char *)rep + (uintptr_t)addr - (uintptr_t)pop;
rep->memcpy_persist_local(raddr, addr, len);
rep = rep->replica;
}
pop->persist_local(addr, len);
}
示例2: sizeof
/*
* pmemobj_open_common -- open a transactional memory pool (set)
*
* This routine does all the work, but takes a cow flag so internal
* calls can map a read-only pool if required.
*/
static PMEMobjpool *
pmemobj_open_common(const char *path, const char *layout, int cow, int boot)
{
LOG(3, "path %s layout %s cow %d", path, layout, cow);
struct pool_set *set;
if (util_pool_open(&set, path, cow, PMEMOBJ_MIN_POOL,
roundup(sizeof (struct pmemobjpool), Pagesize),
OBJ_HDR_SIG, OBJ_FORMAT_MAJOR,
OBJ_FORMAT_COMPAT, OBJ_FORMAT_INCOMPAT,
OBJ_FORMAT_RO_COMPAT) != 0) {
LOG(2, "cannot open pool or pool set");
return NULL;
}
ASSERT(set->nreplicas > 0);
/* read-only mode is not supported in libpmemobj */
if (set->rdonly) {
ERR("read-only mode is not supported");
errno = EINVAL;
goto err;
}
PMEMobjpool *pop;
for (unsigned r = 0; r < set->nreplicas; r++) {
struct pool_replica *rep = set->replica[r];
pop = rep->part[0].addr;
VALGRIND_REMOVE_PMEM_MAPPING(&pop->addr,
sizeof (struct pmemobjpool) -
((uintptr_t)&pop->addr - (uintptr_t)&pop->hdr));
pop->addr = pop;
pop->size = rep->repsize;
if (pmemobj_descr_check(pop, layout, set->poolsize) != 0) {
LOG(2, "descriptor check failed");
goto err;
}
/* initialize replica runtime - is_pmem, funcs, ... */
if (pmemobj_replica_init(pop, rep->is_pmem) != 0) {
ERR("pool initialization failed");
goto err;
}
/* link replicas */
if (r < set->nreplicas - 1)
pop->replica = set->replica[r + 1]->part[0].addr;
}
/*
* If there is more than one replica, check if all of them are
* consistent (recoverable).
* On success, choose any replica and copy entire lanes (redo logs)
* to all the other replicas to synchronize them.
*/
if (set->nreplicas > 1) {
for (unsigned r = 0; r < set->nreplicas; r++) {
pop = set->replica[r]->part[0].addr;
if (pmemobj_check_basic(pop) == 0) {
ERR("inconsistent replica #%u", r);
goto err;
}
}
/* copy lanes */
pop = set->replica[0]->part[0].addr;
void *src = (void *)((uintptr_t)pop + pop->lanes_offset);
size_t len = pop->nlanes * sizeof (struct lane_layout);
for (unsigned r = 1; r < set->nreplicas; r++) {
pop = set->replica[r]->part[0].addr;
void *dst = (void *)((uintptr_t)pop +
pop->lanes_offset);
pop->memcpy_persist_local(dst, src, len);
}
}
pop = set->replica[0]->part[0].addr;
pop->is_master_replica = 1;
for (unsigned r = 1; r < set->nreplicas; r++) {
PMEMobjpool *rep = set->replica[r]->part[0].addr;
rep->is_master_replica = 0;
}
#ifdef USE_VG_MEMCHECK
heap_vg_open(pop);
#endif
VALGRIND_DO_CREATE_MEMPOOL(pop, 0, 0);
//.........这里部分代码省略.........