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::set_thread_count()</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="env.html" title="Chapter 5. The DbEnv Handle" /> 11 <link rel="prev" href="envset_shm_key.html" title="DbEnv::set_shm_key()" /> 12 <link rel="next" href="envset_thread_id.html" title="DbEnv::set_thread_id()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbEnv::set_thread_count()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envset_shm_key.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 5. 23 The DbEnv Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="envset_thread_id.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="envset_thread_count"></a>DbEnv::set_thread_count()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbEnv::set_thread_count(u_int32_t count); </pre> 42 <p> 43 Declare an approximate number of threads in the database environment. 44 The <code class="methodname">DbEnv::set_thread_count()</code> method must be called prior to opening 45 the database environment if the 46 <a class="xref" href="envfailchk.html" title="DbEnv::failchk()">DbEnv::failchk()</a> method will 47 be used. The <code class="methodname">DbEnv::set_thread_count()</code> method does not set the 48 maximum number of threads but is used to determine memory sizing and 49 the thread control block reclamation policy. 50 </p> 51 <p> 52 If a process has not configured an <span class="bold"><strong>is_alive</strong></span> function from the 53 <a class="xref" href="envset_isalive.html" title="DbEnv::set_isalive()">DbEnv::set_isalive()</a> 54 method, and then attempts to join a database environment configured 55 for failure checking with the <a class="xref" href="envfailchk.html" title="DbEnv::failchk()">DbEnv::failchk()</a>, 56 <a class="xref" href="envset_thread_id.html" title="DbEnv::set_thread_id()">DbEnv::set_thread_id()</a>, 57 <a class="xref" href="envset_isalive.html" title="DbEnv::set_isalive()">DbEnv::set_isalive()</a> and 58 <code class="methodname">DbEnv::set_thread_count()</code> methods, the program may be unable to 59 allocate a thread control block and fail to join the environment. 60 <span class="bold"><strong>This is true of the standalone Berkeley DB 61 utility programs.</strong></span> To avoid problems when using the 62 standalone Berkeley DB utility programs with environments configured 63 for failure checking, incorporate the utility's functionality directly 64 in the application, or call the 65 <a class="xref" href="envfailchk.html" title="DbEnv::failchk()">DbEnv::failchk()</a> method 66 before running the utility. 67 </p> 68 <p> 69 The database environment's thread count may also be configured using 70 the environment's <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file. The 71 syntax of the entry in that file is a single line with the string 72 "set_thread_count", one or more whitespace characters, and the thread 73 count. Because the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> file is 74 read when the database environment is opened, it will silently 75 overrule configuration done before that time. 76 </p> 77 <p> 78 The <code class="methodname">DbEnv::set_thread_count()</code> method configures operations performed 79 using the specified <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle, not all 80 operations performed on the underlying database environment. 81 </p> 82 <p> 83 The <code class="methodname">DbEnv::set_thread_count()</code> method may not be called after the 84 <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> method is 85 called. 86 </p> 87 <p> 88 The <code class="methodname">DbEnv::set_thread_count()</code> <span> 89 90 <span> 91 method either returns a non-zero error value or throws an 92 exception that encapsulates a non-zero error value on 93 failure, and returns 0 on success. 94 </span> 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="id1674565"></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="id1674818"></a>count</h4> 110 </div> 111 </div> 112 </div> 113 <p> 114 The <span class="bold"><strong>count</strong></span> parameter is an approximate 115 thread count for the database environment. 116 </p> 117 </div> 118 </div> 119 <div class="sect2" lang="en" xml:lang="en"> 120 <div class="titlepage"> 121 <div> 122 <div> 123 <h3 class="title"><a id="id1674967"></a>Errors</h3> 124 </div> 125 </div> 126 </div> 127 <p> 128 The <code class="methodname">DbEnv::set_thread_count()</code> <span> 129 130 <span> 131 method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> 132 exception, encapsulating one of the following non-zero errors, or return one 133 of the following non-zero errors: 134 </span> 135 </span> 136 </p> 137 <div class="sect3" lang="en" xml:lang="en"> 138 <div class="titlepage"> 139 <div> 140 <div> 141 <h4 class="title"><a id="id1674981"></a>EINVAL</h4> 142 </div> 143 </div> 144 </div> 145 <p> 146 If the method was called after <a class="xref" href="envopen.html" title="DbEnv::open()">DbEnv::open()</a> 147 was called; or if an invalid flag value or parameter was specified. 148 </p> 149 </div> 150 </div> 151 <div class="sect2" lang="en" xml:lang="en"> 152 <div class="titlepage"> 153 <div> 154 <div> 155 <h3 class="title"><a id="id1674982"></a>Class</h3> 156 </div> 157 </div> 158 </div> 159 <p> 160 <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> 161 </p> 162 </div> 163 <div class="sect2" lang="en" xml:lang="en"> 164 <div class="titlepage"> 165 <div> 166 <div> 167 <h3 class="title"><a id="id1675050"></a>See Also</h3> 168 </div> 169 </div> 170 </div> 171 <p> 172 <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> 173 </p> 174 </div> 175 </div> 176 <div class="navfooter"> 177 <hr /> 178 <table width="100%" summary="Navigation footer"> 179 <tr> 180 <td width="40%" align="left"><a accesskey="p" href="envset_shm_key.html">Prev</a> </td> 181 <td width="20%" align="center"> 182 <a accesskey="u" href="env.html">Up</a> 183 </td> 184 <td width="40%" align="right"> <a accesskey="n" href="envset_thread_id.html">Next</a></td> 185 </tr> 186 <tr> 187 <td width="40%" align="left" valign="top">DbEnv::set_shm_key() </td> 188 <td width="20%" align="center"> 189 <a accesskey="h" href="index.html">Home</a> 190 </td> 191 <td width="40%" align="right" valign="top"> DbEnv::set_thread_id()</td> 192 </tr> 193 </table> 194 </div> 195 </body> 196</html> 197