Debian Codegraph @

docs/api_reference/C/mempregister.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <title>DB_ENV-&gt;memp_register()</title>
7 <link rel="stylesheet" href="apiReference.css" type="text/css" />
8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" />
10 <link rel="up" href="memp.html" title="Chapter 8.  The DB_MPOOLFILE Handle" />
11 <link rel="prev" href="mempfcreate.html" title="DB_ENV-&gt;memp_fcreate()" />
12 <link rel="next" href="mempstat.html" title="DB_ENV-&gt;memp_stat()" />
13 </head>
14 <body>
15 <div xmlns="" class="navheader">
16 <div class="libver">
17 <p>Library Version 11.2.5.3</p>
18 </div>
19 <table width="100%" summary="Navigation header">
20 <tr>
21 <th colspan="3" align="center">DB_ENV-&gt;memp_register()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="mempfcreate.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 8. 
26 The DB_MPOOLFILE Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="mempstat.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="sect1" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title" style="clear: both"><a id="mempregister"></a>DB_ENV-&gt;memp_register()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DB_ENV-&gt;memp_register(DB_ENV *env, int ftype,
45 int (*pgin_fcn)(DB_ENV *env, db_pgno_t pgno, void *pgaddr,
46 DBT *pgcookie), int (*pgout_fcn)(DB_ENV *env, db_pgno_t pgno,
47 void *pgaddr, DBT *pgcookie)); </pre>
48 <p>
49 The <code class="methodname">DB_ENV-&gt;memp_register()</code> method registers page-in and page-out
50 functions for files of type <span class="bold"><strong>ftype</strong></span> in the cache.
51 </p>
52 <p>
53 If the <span class="bold"><strong>pgin_fcn</strong></span> function is non-NULL,
54 it is called each time a page is read into the cache from a file
55 of type <span class="bold"><strong>ftype</strong></span>, or a page is created
56 for a file of type <span class="bold"><strong>ftype</strong></span> (see the
57 DB_MPOOL_CREATE flag for the
58 <a class="xref" href="mempfget.html" title="DB_MPOOLFILE-&gt;get()">DB_MPOOLFILE-&gt;get()</a> method).
59 </p>
60 <p>
61 If the <span class="bold"><strong>pgout_fcn</strong></span> function is
62 non-NULL, it is called each time a page is written to a file of type
63 <span class="bold"><strong>ftype</strong></span>.
64 </p>
65 <p>
66 The purpose of the <code class="methodname">DB_ENV-&gt;memp_register()</code> function is to support
67 processing when pages are entered into, or flushed from, the cache. For example, this
68 functionality might be used to do byte-endian conversion as pages are read from, or written
69 to, the underlying file.
70 </p>
71 <p>
72 A file type must be specified to make it possible for unrelated
73 threads or processes that are sharing a cache, to evict each other's
74 pages from the cache. During initialization, applications should call
75 <code class="methodname">DB_ENV-&gt;memp_register()</code> for each type of file requiring input or
76 output processing that will be sharing the underlying cache. (No
77 registry is necessary for the standard Berkeley DB access method types
78 because <a class="xref" href="dbopen.html" title="DB-&gt;open()">DB-&gt;open()</a>
79 registers them separately.)
80 </p>
81 <p>
82 If a thread or process does not call <code class="methodname">DB_ENV-&gt;memp_register()</code> for a
83 file type, it is impossible for it to evict pages for any file
84 requiring input or output processing from the cache. For this reason,
85 <code class="methodname">DB_ENV-&gt;memp_register()</code> should always be called by each application
86 sharing a cache for each type of file included in the cache, regardless
87 of whether or not the application itself uses files of that type.
88 </p>
89 <p>
90 The <code class="methodname">DB_ENV-&gt;memp_register()</code> <span>
91 <span>
92 method returns a non-zero error value on failure and 0 on success.
93 </span>
94
95 </span>
96 </p>
97 <div class="sect2" lang="en" xml:lang="en">
98 <div class="titlepage">
99 <div>
100 <div>
101 <h3 class="title"><a id="idp53217192"></a>Parameters</h3>
102 </div>
103 </div>
104 </div>
105 <div class="sect3" lang="en" xml:lang="en">
106 <div class="titlepage">
107 <div>
108 <div>
109 <h4 class="title"><a id="idp53217576"></a>ftype</h4>
110 </div>
111 </div>
112 </div>
113 <p>
114 The <span class="bold"><strong>ftype</strong></span> parameter specifies the
115 type of file for which the page-in and page-out functions will be
116 called.
117 </p>
118 <p>
119 The <span class="bold"><strong>ftype</strong></span> value for a file must be a
120 non-zero positive number less than 128 (0 and negative numbers are
121 reserved for internal use by the Berkeley DB library).
122 </p>
123 </div>
124 <div class="sect3" lang="en" xml:lang="en">
125 <div class="titlepage">
126 <div>
127 <div>
128 <h4 class="title"><a id="idp53207856"></a>pgin_fcn, pgout_fcn</h4>
129 </div>
130 </div>
131 </div>
132 <p>
133 The page-in and page-out functions.
134 </p>
135 <p>
136 The <span class="bold"><strong>pgin_fcn</strong></span> and <span class="bold"><strong>pgout_fcn</strong></span> functions are called with a reference
137 to the current database environment, the page number being read or
138 written, a pointer to the page being read or written, and any
139 parameter <span class="bold"><strong>pgcookie</strong></span> that was specified
140 to the <a class="xref" href="mempset_pgcookie.html" title="DB_MPOOLFILE-&gt;set_pgcookie()">DB_MPOOLFILE-&gt;set_pgcookie()</a>
141 method.
142 </p>
143 <p>
144 The <span class="bold"><strong>pgin_fcn</strong></span> and <span class="bold"><strong>pgout_fcn</strong></span> functions should return 0 on success,
145 and a non-zero value on failure, in which case the shared Berkeley DB
146 library function calling it will also fail, returning that non-zero
147 value. The non-zero value should be selected from values outside of
148 the Berkeley DB library namespace.
149 </p>
150 </div>
151 </div>
152 <div class="sect2" lang="en" xml:lang="en">
153 <div class="titlepage">
154 <div>
155 <div>
156 <h3 class="title"><a id="idp53205536"></a>Class</h3>
157 </div>
158 </div>
159 </div>
160 <p>
161 <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a>, <a class="link" href="memp.html" title="Chapter 8.  The DB_MPOOLFILE Handle">DB_MPOOLFILE</a>
162 </p>
163 </div>
164 <div class="sect2" lang="en" xml:lang="en">
165 <div class="titlepage">
166 <div>
167 <div>
168 <h3 class="title"><a id="idp53225320"></a>See Also</h3>
169 </div>
170 </div>
171 </div>
172 <p>
173 <a class="xref" href="memp.html#memplist" title="Memory Pools and Related Methods">Memory Pools and Related Methods</a>
174 </p>
175 </div>
176 </div>
177 <div class="navfooter">
178 <hr />
179 <table width="100%" summary="Navigation footer">
180 <tr>
181 <td width="40%" align="left"><a accesskey="p" href="mempfcreate.html">Prev</a> </td>
182 <td width="20%" align="center">
183 <a accesskey="u" href="memp.html">Up</a>
184 </td>
185 <td width="40%" align="right"> <a accesskey="n" href="mempstat.html">Next</a></td>
186 </tr>
187 <tr>
188 <td width="40%" align="left" valign="top">DB_ENV-&gt;memp_fcreate() </td>
189 <td width="20%" align="center">
190 <a accesskey="h" href="index.html">Home</a>
191 </td>
192 <td width="40%" align="right" valign="top"> DB_ENV-&gt;memp_stat()</td>
193 </tr>
194 </table>
195 </div>
196 </body>
197 </html>