Question about the root object

34 views
Skip to first unread message

Xin Zhang

unread,
Sep 6, 2017, 9:07:02 PM9/6/17
to pmem
Hi all,

the root object is unique object for a pool or it can be created as different instances many times in a pool, if so, how to manage so many root objects. In the example, only has one root, I just wondering if there is multi-root objects, how to handle them?

Thanks,
Xin



 

Krzysztof Czurylo

unread,
Sep 7, 2017, 6:37:20 AM9/7/17
to pmem
Hi Xin,

As stated in pmemobj man page, there is exactly one root object per pool.
If you need to store more than one data structure in a pool (two or more lists, trees, etc.), then the root object structure can hold OIDs to all of them, i.e.:

POBJ_LAYOUT_BEGIN(my_layout);
POBJ_LAYOUT_ROOT(my_layout, struct my_root);
POBJ_LAYOUT_TOID(my_layout, struct my_list);
POBJ_LAYOUT_END(my_layout);

struct my_root {
        TOID(my_list) list1;
        TOID(my_list) list2;
        /* could be more "roots" here */
};

struct my_list {
        ...
};

--
krzycz

Xin Zhang

unread,
Sep 7, 2017, 9:02:38 PM9/7/17
to pmem
Thank you!
Is that possible that list can be write back to the pmemory by portion of it? For example, write 100 items in one list per time. Or it is that write back all the items in the list into pmemory only once?
Reply all
Reply to author
Forward
0 new messages