MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / mtx_init

Function mtx_init

deps/jemalloc/test/src/mtx.c:7–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5#endif
6
7bool
8mtx_init(mtx_t *mtx) {
9#ifdef _WIN32
10 if (!InitializeCriticalSectionAndSpinCount(&mtx->lock,
11 _CRT_SPINCOUNT)) {
12 return true;
13 }
14#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
15 mtx->lock = OS_UNFAIR_LOCK_INIT;
16#else
17 pthread_mutexattr_t attr;
18
19 if (pthread_mutexattr_init(&attr) != 0) {
20 return true;
21 }
22 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT);
23 if (pthread_mutex_init(&mtx->lock, &attr) != 0) {
24 pthread_mutexattr_destroy(&attr);
25 return true;
26 }
27 pthread_mutexattr_destroy(&attr);
28#endif
29 return false;
30}
31
32void
33mtx_fini(mtx_t *mtx) {

Callers 1

mtx.cFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected