1<!--$Id: env_set_thread_count.so,v 10.3 2007/04/02 16:08:13 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DB_ENV->set_thread_count</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DB_ENV->set_thread_count</b> 14</td> 15<td align=right> 16<a href="/api_c/api_core.html"><img src="/images/api.gif" alt="API"></a> 17<a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db.h> 23<p> 24int 25DB_ENV->set_thread_count(DB_ENV *dbenv, u_int32_t count); 26<p> 27int 28DB_ENV->get_thread_count(DB_ENV *dbenv, u_int32_t *countp); 29</pre></b> 30<hr size=1 noshade> 31<b>Description: DB_ENV->set_thread_count</b> 32<p>Declare an approximate number of threads in the database environment. 33The DB_ENV->set_thread_count method must be called prior to opening the 34database environment if the <a href="/api_c/env_failchk.html">DB_ENV->failchk</a> method will be used. The 35DB_ENV->set_thread_count method does not set the maximum number of 36threads but is used to determine memory sizing and the thread control 37block reclamation policy.</p> 38<p>If a process has not configured an <b>is_alive</b> function from the 39<a href="/api_c/env_set_isalive.html">DB_ENV->set_isalive</a> method, and then attempts to join a database 40environment configured for failure checking with the 41<a href="/api_c/env_failchk.html">DB_ENV->failchk</a>, <a href="/api_c/env_set_thread_id.html">DB_ENV->set_thread_id</a>, 42<a href="/api_c/env_set_isalive.html">DB_ENV->set_isalive</a> and DB_ENV->set_thread_count methods, the 43program may be unable to allocate a thread control block and fail to 44join the environment. 45<b>This is true of the standalone Berkeley DB utility programs.</b> 46To avoid problems when using the standalone Berkeley DB utility programs with 47environments configured for failure checking, incorporate the utility's 48functionality directly in the application, or call the 49<a href="/api_c/env_failchk.html">DB_ENV->failchk</a> method before running the utility.</p> 50<p>The database environment's thread count may also be configured using the 51environment's <a href="/ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file. The syntax of the entry in that 52file is a single line with the string "set_thread_count", one or more whitespace 53characters, and the thread count. 54Because the <a href="/ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file is read when the database environment 55is opened, it will silently overrule configuration done before that 56time.</p> 57<p>The DB_ENV->set_thread_count method configures operations performed using the specified 58<a href="/api_c/env_class.html">DB_ENV</a> handle, not all operations performed on the underlying 59database environment.</p> 60<p>The DB_ENV->set_thread_count method may not be called after the <a href="/api_c/env_open.html">DB_ENV->open</a> method is 61called. 62</p> 63<p>The DB_ENV->set_thread_count method 64returns a non-zero error value on failure 65and 0 on success. 66</p> 67<b>Parameters</b> <br> 68 <b>count</b><ul compact><li>The <b>count</b> parameter is an approximate thread count for the 69database environment.</ul> 70<br> 71<br><b>Errors</b> 72<p>The DB_ENV->set_thread_count method 73may fail and return one of the following non-zero errors:</p> 74<br> 75<b>EINVAL</b><ul compact><li>If the method was called after <a href="/api_c/env_open.html">DB_ENV->open</a> was called; or if an 76invalid flag value or parameter was specified.</ul> 77<br> 78<hr size=1 noshade> 79<b>Description: DB_ENV->get_thread_count</b> 80<p>The DB_ENV->get_thread_count method returns the thread count.</p> 81<p>The DB_ENV->get_thread_count method may be called at any time during the life of the 82application.</p> 83<p>The DB_ENV->get_thread_count method 84returns a non-zero error value on failure 85and 0 on success. 86</p> 87<b>Parameters</b> <br> 88 <b>countp</b><ul compact><li>The DB_ENV->get_thread_count method returns the 89thread count in <b>countp</b>.</ul> 90<br> 91<hr size=1 noshade> 92<br><b>Class</b> 93<a href="/api_c/env_class.html">DB_ENV</a> 94<br><b>See Also</b> 95<a href="/api_c/env_list.html">Database Environments and Related Methods</a> 96</tt> 97<table width="100%"><tr><td><br></td><td align=right> 98<a href="/api_c/api_core.html"><img src="/images/api.gif" alt="API"></a><a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a> 99</td></tr></table> 100<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 101</body> 102</html> 103