File: pmemobj_first.3

package info (click to toggle)
pmdk 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 31,076 kB
  • sloc: ansic: 144,239; sh: 29,351; cpp: 10,136; perl: 5,122; makefile: 3,531; pascal: 1,383; python: 677
file content (123 lines) | stat: -rw-r--r-- 5,276 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
.\" Automatically generated by Pandoc 2.1.3
.\"
.TH "PMEMOBJ_FIRST" "3" "2018-07-18" "PMDK - pmemobj API version 2.3" "PMDK Programmer's Manual"
.hy
.\" Copyright 2014-2018, Intel Corporation
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\"     * Redistributions of source code must retain the above copyright
.\"       notice, this list of conditions and the following disclaimer.
.\"
.\"     * Redistributions in binary form must reproduce the above copyright
.\"       notice, this list of conditions and the following disclaimer in
.\"       the documentation and/or other materials provided with the
.\"       distribution.
.\"
.\"     * Neither the name of the copyright holder nor the names of its
.\"       contributors may be used to endorse or promote products derived
.\"       from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.SH NAME
.PP
\f[B]pmemobj_first\f[](), \f[B]pmemobj_next\f[](),
\f[B]POBJ_FIRST\f[](), \f[B]POBJ_FIRST_TYPE_NUM\f[](),
\f[B]POBJ_NEXT\f[](), \f[B]POBJ_NEXT_TYPE_NUM\f[](),
\f[B]POBJ_FOREACH\f[](), \f[B]POBJ_FOREACH_SAFE\f[](),
\f[B]POBJ_FOREACH_TYPE\f[](), \f[B]POBJ_FOREACH_SAFE_TYPE\f[]() \-
pmemobj container operations
.SH SYNOPSIS
.IP
.nf
\f[C]
#include\ <libpmemobj.h>

PMEMoid\ pmemobj_first(PMEMobjpool\ *pop);
PMEMoid\ pmemobj_next(PMEMoid\ oid);

POBJ_FIRST(PMEMobjpool\ *pop,\ TYPE)
POBJ_FIRST_TYPE_NUM(PMEMobjpool\ *pop,\ uint64_t\ type_num)
POBJ_NEXT(TOID\ oid)
POBJ_NEXT_TYPE_NUM(PMEMoid\ oid)

POBJ_FOREACH(PMEMobjpool\ *pop,\ PMEMoid\ varoid)
POBJ_FOREACH_SAFE(PMEMobjpool\ *pop,\ PMEMoid\ varoid,\ PMEMoid\ nvaroid)
POBJ_FOREACH_TYPE(PMEMobjpool\ *pop,\ TOID\ var)
POBJ_FOREACH_SAFE_TYPE(PMEMobjpool\ *pop,\ TOID\ var,\ TOID\ nvar)
\f[]
.fi
.SH DESCRIPTION
.PP
The \f[B]libpmemobj\f[](7) container operations provide a mechanism that
allows iteration through the internal object collection, either looking
for a specific object, or performing a specific operation on each object
of a given type.
Software should not make any assumptions about the order of the objects
in the internal object containers.
.PP
The \f[B]pmemobj_first\f[]() function returns the first object from the
pool.
.PP
The \f[B]POBJ_FIRST\f[]() macro returns the first object from the pool
of the type specified by \f[I]TYPE\f[].
.PP
The \f[B]POBJ_FIRST_TYPE_NUM\f[]() macro returns the first object from
the pool of the type specified by \f[I]type_num\f[].
.PP
The \f[B]pmemobj_next\f[]() function returns the next object from the
pool.
.PP
The \f[B]POBJ_NEXT\f[]() macro returns the next object of the same type
as the object referenced by \f[I]oid\f[].
.PP
The \f[B]POBJ_NEXT_TYPE_NUM\f[]() macro returns the next object of the
same type number as the object referenced by \f[I]oid\f[].
.PP
The following four macros provide a more convenient way to iterate
through the internal collections, performing a specific operation on
each object.
.PP
The \f[B]POBJ_FOREACH\f[]() macro performs a specific operation on each
allocated object stored in the persistent memory pool \f[I]pop\f[].
It traverses the internal collection of all the objects, assigning a
handle to each element in turn to \f[I]varoid\f[].
.PP
The \f[B]POBJ_FOREACH_TYPE\f[]() macro performs a specific operation on
each allocated object stored in the persistent memory pool \f[I]pop\f[]
that has the same type as \f[I]var\f[].
It traverses the internal collection of all the objects of the specified
type, assigning a handle to each element in turn to \f[I]var\f[].
.PP
The macros \f[B]POBJ_FOREACH_SAFE\f[]() and
\f[B]POBJ_FOREACH_SAFE_TYPE\f[]() work in a similar fashion as
\f[B]POBJ_FOREACH\f[]() and \f[B]POBJ_FOREACH_TYPE\f[](), except that
prior to performing the operation on the object, they preserve a handle
to the next object in the collection by assigning it to \f[I]nvaroid\f[]
or \f[I]nvar\f[], respectively.
This allows safe deletion of selected objects while iterating through
the collection.
.SH RETURN VALUE
.PP
\f[B]pmemobj_first\f[]() returns the first object from the pool, or, if
the pool is empty, \f[B]OID_NULL\f[].
.PP
\f[B]pmemobj_next\f[]() returns the next object from the pool.
If the object referenced by \f[I]oid\f[] is the last object in the
collection, or if \f[I]oid\f[] is \f[I]OID_NULL\f[],
\f[B]pmemobj_next\f[]() returns \f[B]OID_NULL\f[].
.SH SEE ALSO
.PP
\f[B]libpmemobj\f[](7) and \f[B]<http://pmem.io>\f[]