DB_ENV->set_thread_count()

#include <db.h>

int
DB_ENV->set_thread_count(DB_ENV *dbenv, u_int32_t count);  

Declare an approximate number of threads in the database environment. This method allocates resources in your environment for the threads your application will use. If you fail to properly estimate the number of threads your application will use, your application will run out of resources and errors will be returned when the application attempts to start one too many threads.

The DB_ENV->set_thread_count() method does not set the maximum number of threads but is used to determine memory sizing and the thread control block reclamation policy.

The DB_ENV->set_thread_count() method must be called prior to opening the database environment. In addition, this method must be used with the DB_ENV->failchk() method.

If a process invokes this method without the use of DB_ENV->failchk() the program may be unable to allocate a thread control block. This is true of the standalone Berkeley DB utility programs.

If a process has not configured an is_alive function from the DB_ENV->set_isalive() method, and then attempts to join a database environment configured for failure checking with the DB_ENV->failchk(), DB_ENV->set_thread_id(), DB_ENV->set_isalive() and DB_ENV->set_thread_count() methods, the program may be unable to allocate a thread control block and fail to join the environment. This is true of the standalone Berkeley DB utility programs. To avoid problems when using the standalone Berkeley DB utility programs with environments configured for failure checking, incorporate the utility's functionality directly in the application, or call the DB_ENV->failchk() method before running the utility.

The database environment's thread count may also be configured using the environment's DB_CONFIG file. The syntax of the entry in that file is a single line with the string "set_thread_count", one or more whitespace characters, and the thread count. Because the DB_CONFIG file is read when the database environment is opened, it will silently overrule configuration done before that time.

The DB_ENV->set_thread_count() method configures operations performed using the specified DB_ENV handle, not all operations performed on the underlying database environment.

The DB_ENV->set_thread_count() method may not be called after the DB_ENV->open() method is called.

The DB_ENV->set_thread_count() method returns a non-zero error value on failure and 0 on success.

Parameters

count

The count parameter is an approximate thread count for the database environment.

Errors

The DB_ENV->set_thread_count() method may fail and return one of the following non-zero errors:

EINVAL

If the method was called after DB_ENV->open() was called; or if an invalid flag value or parameter was specified.

Class

DB_ENV

See Also

Database Environments and Related Methods