Small. Fast. Reliable.
Choose any three.

About Sitemap Documentation Download License News Developers Support

## SQLite C Interface

## Test To See If The Library Is Threadsafe

>     int sqlite3_threadsafe(void);

SQLite can be compiled with or without mutexes. When the SQLITE_THREADSAFE C preprocessor macro is true, mutexes are enabled and SQLite is threadsafe. When that macro is false, the mutexes are omitted. Without the mutexes, it is not safe to use SQLite concurrently from more than one thread.

Enabling mutexes incurs a measurable performance penalty. So if speed is of utmost importance, it makes sense to disable the mutexes. But for maximum safety, mutexes should be enabled. The default behavior is for mutexes to be enabled.

This interface can be used by a program to make sure that the version of SQLite that it is linking against was compiled with the desired setting of the SQLITE_THREADSAFE macro.

This interface only reports on the compile-time mutex setting of the SQLITE_THREADSAFE flag. If SQLite is compiled with SQLITE_THREADSAFE=1 then mutexes are enabled by default but can be fully or partially disabled using a call to sqlite3_config() with the verbs SQLITE_CONFIG_SINGLETHREAD, SQLITE_CONFIG_MULTITHREAD, or SQLITE_CONFIG_MUTEX. The return value of this function shows only the default compile-time setting, not any run-time changes to that setting.

### Invariants:

H10101 | The sqlite3_threadsafe() function shall return nonzero if SQLite was compiled with the its mutexes enabled by default or zero if SQLite was compiled such that mutexes are permanently disabled.
H10102 | The value returned by the sqlite3_threadsafe() function shall not change when mutex setting are modified at runtime using the sqlite3_config() interface and especially the SQLITE_CONFIG_SINGLETHREAD, SQLITE_CONFIG_MULTITHREAD, SQLITE_CONFIG_SERIALIZED, and SQLITE_CONFIG_MUTEX verbs.

See also lists of Objects, Constants, and Functions.

This page last modified 2008/08/11 17:57:43 UTC