| 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>DbEnv::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 9. The DbMpoolFile Handle" /> |
| 11 | <link rel="prev" href="mempfcreate.html" title="DbEnv::memp_fcreate()" /> |
| 12 | <link rel="next" href="mempstat.html" title="DbEnv::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">DbEnv::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 9. |
| 26 | The DbMpoolFile 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>DbEnv::memp_register()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db_cxx.h> |
| 42 | |
| 43 | extern "C" { |
| 44 | typedef int (*pgin_fcn_type)(DB_ENV *dbenv, |
| 45 | db_pgno_t pgno, void *pgaddr, DBT *pgcookie); |
| 46 | typedef int (*pgout_fcn_type)(DB_ENV *dbenv, |
| 47 | db_pgno_t pgno, void *pgaddr, DBT *pgcookie); |
| 48 | }; |
| 49 | int |
| 50 | DbEnv::memp_register(int ftype, |
| 51 | pgin_fcn_type pgin_fcn, pgout_fcn_type pgout_fcn);</pre> |
| 52 | <p> |
| 53 | The <code class="methodname">DbEnv::memp_register()</code> method registers page-in and page-out |
| 54 | functions for files of type <span class="bold"><strong>ftype</strong></span> in the cache. |
| 55 | </p> |
| 56 | <p> |
| 57 | If the <span class="bold"><strong>pgin_fcn</strong></span> function is non-NULL, |
| 58 | it is called each time a page is read into the cache from a file |
| 59 | of type <span class="bold"><strong>ftype</strong></span>, or a page is created |
| 60 | for a file of type <span class="bold"><strong>ftype</strong></span> (see the |
| 61 | DB_MPOOL_CREATE flag for the |
| 62 | <a class="xref" href="mempfget.html" title="DbMpoolFile::get()">DbMpoolFile::get()</a> method). |
| 63 | </p> |
| 64 | <p> |
| 65 | If the <span class="bold"><strong>pgout_fcn</strong></span> function is |
| 66 | non-NULL, it is called each time a page is written to a file of type |
| 67 | <span class="bold"><strong>ftype</strong></span>. |
| 68 | </p> |
| 69 | <p> |
| 70 | The purpose of the <code class="methodname">DbEnv::memp_register()</code> function is to support |
| 71 | processing when pages are entered into, or flushed from, the cache. For example, this |
| 72 | functionality might be used to do byte-endian conversion as pages are read from, or written |
| 73 | to, the underlying file. |
| 74 | </p> |
| 75 | <p> |
| 76 | A file type must be specified to make it possible for unrelated |
| 77 | threads or processes that are sharing a cache, to evict each other's |
| 78 | pages from the cache. During initialization, applications should call |
| 79 | <code class="methodname">DbEnv::memp_register()</code> for each type of file requiring input or |
| 80 | output processing that will be sharing the underlying cache. (No |
| 81 | registry is necessary for the standard Berkeley DB access method types |
| 82 | because <a class="xref" href="dbopen.html" title="Db::open()">Db::open()</a> |
| 83 | registers them separately.) |
| 84 | </p> |
| 85 | <p> |
| 86 | If a thread or process does not call <code class="methodname">DbEnv::memp_register()</code> for a |
| 87 | file type, it is impossible for it to evict pages for any file |
| 88 | requiring input or output processing from the cache. For this reason, |
| 89 | <code class="methodname">DbEnv::memp_register()</code> should always be called by each application |
| 90 | sharing a cache for each type of file included in the cache, regardless |
| 91 | of whether or not the application itself uses files of that type. |
| 92 | </p> |
| 93 | <p> |
| 94 | The <code class="methodname">DbEnv::memp_register()</code> <span> |
| 95 | |
| 96 | <span> |
| 97 | method either returns a non-zero error value or throws an |
| 98 | exception that encapsulates a non-zero error value on |
| 99 | failure, and returns 0 on success. |
| 100 | </span> |
| 101 | </span> |
| 102 | </p> |
| 103 | <div class="sect2" lang="en" xml:lang="en"> |
| 104 | <div class="titlepage"> |
| 105 | <div> |
| 106 | <div> |
| 107 | <h3 class="title"><a id="idp8668424"></a>Parameters</h3> |
| 108 | </div> |
| 109 | </div> |
| 110 | </div> |
| 111 | <div class="sect3" lang="en" xml:lang="en"> |
| 112 | <div class="titlepage"> |
| 113 | <div> |
| 114 | <div> |
| 115 | <h4 class="title"><a id="idp8667776"></a>ftype</h4> |
| 116 | </div> |
| 117 | </div> |
| 118 | </div> |
| 119 | <p> |
| 120 | The <span class="bold"><strong>ftype</strong></span> parameter specifies the |
| 121 | type of file for which the page-in and page-out functions will be |
| 122 | called. |
| 123 | </p> |
| 124 | <p> |
| 125 | The <span class="bold"><strong>ftype</strong></span> value for a file must be a |
| 126 | non-zero positive number less than 128 (0 and negative numbers are |
| 127 | reserved for internal use by the Berkeley DB library). |
| 128 | </p> |
| 129 | </div> |
| 130 | <div class="sect3" lang="en" xml:lang="en"> |
| 131 | <div class="titlepage"> |
| 132 | <div> |
| 133 | <div> |
| 134 | <h4 class="title"><a id="idp8662848"></a>pgin_fcn, pgout_fcn</h4> |
| 135 | </div> |
| 136 | </div> |
| 137 | </div> |
| 138 | <p> |
| 139 | The page-in and page-out functions. |
| 140 | </p> |
| 141 | <p> |
| 142 | The <span class="bold"><strong>pgin_fcn</strong></span> and <span class="bold"><strong>pgout_fcn</strong></span> functions are called with a reference |
| 143 | to the current database environment, the page number being read or |
| 144 | written, a pointer to the page being read or written, and any |
| 145 | parameter <span class="bold"><strong>pgcookie</strong></span> that was specified |
| 146 | to the <a class="xref" href="mempset_pgcookie.html" title="DbMpoolFile::set_pgcookie()">DbMpoolFile::set_pgcookie()</a> |
| 147 | method. |
| 148 | </p> |
| 149 | <p> |
| 150 | The <span class="bold"><strong>pgin_fcn</strong></span> and <span class="bold"><strong>pgout_fcn</strong></span> functions should return 0 on success, |
| 151 | and a non-zero value on failure, in which case the shared Berkeley DB |
| 152 | library function calling it will also fail, returning that non-zero |
| 153 | value. The non-zero value should be selected from values outside of |
| 154 | the Berkeley DB library namespace. |
| 155 | </p> |
| 156 | </div> |
| 157 | </div> |
| 158 | <div class="sect2" lang="en" xml:lang="en"> |
| 159 | <div class="titlepage"> |
| 160 | <div> |
| 161 | <div> |
| 162 | <h3 class="title"><a id="idp8656320"></a>Class</h3> |
| 163 | </div> |
| 164 | </div> |
| 165 | </div> |
| 166 | <p> |
| 167 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a>, <a class="link" href="memp.html" title="Chapter 9. The DbMpoolFile Handle">DbMpoolFile</a> |
| 168 | </p> |
| 169 | </div> |
| 170 | <div class="sect2" lang="en" xml:lang="en"> |
| 171 | <div class="titlepage"> |
| 172 | <div> |
| 173 | <div> |
| 174 | <h3 class="title"><a id="idp8675872"></a>See Also</h3> |
| 175 | </div> |
| 176 | </div> |
| 177 | </div> |
| 178 | <p> |
| 179 | <a class="xref" href="memp.html#memplist" title="Memory Pools and Related Methods">Memory Pools and Related Methods</a> |
| 180 | </p> |
| 181 | </div> |
| 182 | </div> |
| 183 | <div class="navfooter"> |
| 184 | <hr /> |
| 185 | <table width="100%" summary="Navigation footer"> |
| 186 | <tr> |
| 187 | <td width="40%" align="left"><a accesskey="p" href="mempfcreate.html">Prev</a> </td> |
| 188 | <td width="20%" align="center"> |
| 189 | <a accesskey="u" href="memp.html">Up</a> |
| 190 | </td> |
| 191 | <td width="40%" align="right"> <a accesskey="n" href="mempstat.html">Next</a></td> |
| 192 | </tr> |
| 193 | <tr> |
| 194 | <td width="40%" align="left" valign="top">DbEnv::memp_fcreate() </td> |
| 195 | <td width="20%" align="center"> |
| 196 | <a accesskey="h" href="index.html">Home</a> |
| 197 | </td> |
| 198 | <td width="40%" align="right" valign="top"> DbEnv::memp_stat()</td> |
| 199 | </tr> |
| 200 | </table> |
| 201 | </div> |
| 202 | </body> |
| 203 | </html> |