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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>DB_ENV->memp_register()</title>
<link rel="stylesheet" href="apiReference.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
<link rel="start" href="index.html" title="Berkeley DB C API Reference" />
<link rel="up" href="memp.html" title="Chapter 8. The DB_MPOOLFILE Handle" />
<link rel="prev" href="mempfcreate.html" title="DB_ENV->memp_fcreate()" />
<link rel="next" href="mempstat.html" title="DB_ENV->memp_stat()" />
</head>
<body>
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">DB_ENV->memp_register()</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="mempfcreate.html">Prev</a> </td>
<th width="60%" align="center">Chapter 8.
The DB_MPOOLFILE Handle
</th>
<td width="20%" align="right"> <a accesskey="n" href="mempstat.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="sect1" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a id="mempregister"></a>DB_ENV->memp_register()</h2>
</div>
</div>
</div>
<pre class="programlisting">#include <db.h>
int
DB_ENV->memp_register(DB_ENV *env, int ftype,
int (*pgin_fcn)(DB_ENV *env, db_pgno_t pgno, void *pgaddr,
DBT *pgcookie), int (*pgout_fcn)(DB_ENV *env, db_pgno_t pgno,
void *pgaddr, DBT *pgcookie)); </pre>
<p>
The <code class="methodname">DB_ENV->memp_register()</code> method registers page-in and page-out
functions for files of type <span class="bold"><strong>ftype</strong></span> in the cache.
</p>
<p>
If the <span class="bold"><strong>pgin_fcn</strong></span> function is non-NULL,
it is called each time a page is read into the cache from a file
of type <span class="bold"><strong>ftype</strong></span>, or a page is created
for a file of type <span class="bold"><strong>ftype</strong></span> (see the
DB_MPOOL_CREATE flag for the
<a class="xref" href="mempfget.html" title="DB_MPOOLFILE->get()">DB_MPOOLFILE->get()</a> method).
</p>
<p>
If the <span class="bold"><strong>pgout_fcn</strong></span> function is
non-NULL, it is called each time a page is written to a file of type
<span class="bold"><strong>ftype</strong></span>.
</p>
<p>
The purpose of the <code class="methodname">DB_ENV->memp_register()</code> function is to support
processing when pages are entered into, or flushed from, the cache. For example, this
functionality might be used to do byte-endian conversion as pages are read from, or written
to, the underlying file.
</p>
<p>
A file type must be specified to make it possible for unrelated
threads or processes that are sharing a cache, to evict each other's
pages from the cache. During initialization, applications should call
<code class="methodname">DB_ENV->memp_register()</code> for each type of file requiring input or
output processing that will be sharing the underlying cache. (No
registry is necessary for the standard Berkeley DB access method types
because <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a>
registers them separately.)
</p>
<p>
If a thread or process does not call <code class="methodname">DB_ENV->memp_register()</code> for a
file type, it is impossible for it to evict pages for any file
requiring input or output processing from the cache. For this reason,
<code class="methodname">DB_ENV->memp_register()</code> should always be called by each application
sharing a cache for each type of file included in the cache, regardless
of whether or not the application itself uses files of that type.
</p>
<p>
The <code class="methodname">DB_ENV->memp_register()</code> <span>
<span>
method returns a non-zero error value on failure and 0 on success.
</span>
</span>
</p>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="idp53048424"></a>Parameters</h3>
</div>
</div>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp53047776"></a>ftype</h4>
</div>
</div>
</div>
<p>
The <span class="bold"><strong>ftype</strong></span> parameter specifies the
type of file for which the page-in and page-out functions will be
called.
</p>
<p>
The <span class="bold"><strong>ftype</strong></span> value for a file must be a
non-zero positive number less than 128 (0 and negative numbers are
reserved for internal use by the Berkeley DB library).
</p>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp53042856"></a>pgin_fcn, pgout_fcn</h4>
</div>
</div>
</div>
<p>
The page-in and page-out functions.
</p>
<p>
The <span class="bold"><strong>pgin_fcn</strong></span> and <span class="bold"><strong>pgout_fcn</strong></span> functions are called with a reference
to the current database environment, the page number being read or
written, a pointer to the page being read or written, and any
parameter <span class="bold"><strong>pgcookie</strong></span> that was specified
to the <a class="xref" href="mempset_pgcookie.html" title="DB_MPOOLFILE->set_pgcookie()">DB_MPOOLFILE->set_pgcookie()</a>
method.
</p>
<p>
The <span class="bold"><strong>pgin_fcn</strong></span> and <span class="bold"><strong>pgout_fcn</strong></span> functions should return 0 on success,
and a non-zero value on failure, in which case the shared Berkeley DB
library function calling it will also fail, returning that non-zero
value. The non-zero value should be selected from values outside of
the Berkeley DB library namespace.
</p>
</div>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="idp53036568"></a>Class</h3>
</div>
</div>
</div>
<p>
<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>
</p>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="idp53055712"></a>See Also</h3>
</div>
</div>
</div>
<p>
<a class="xref" href="memp.html#memplist" title="Memory Pools and Related Methods">Memory Pools and Related Methods</a>
</p>
</div>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="mempfcreate.html">Prev</a> </td>
<td width="20%" align="center">
<a accesskey="u" href="memp.html">Up</a>
</td>
<td width="40%" align="right"> <a accesskey="n" href="mempstat.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">DB_ENV->memp_fcreate() </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> DB_ENV->memp_stat()</td>
</tr>
</table>
</div>
</body>
</html>
|