Commit 469a2bb0 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

refs #5632 add a portability layer for adaptive mutexes

git-svn-id: file:///svn/toku/tokudb@49239 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3131d685
...@@ -13,10 +13,7 @@ void rollback_log_node_cache::init (uint32_t max_num_avail_nodes) { ...@@ -13,10 +13,7 @@ void rollback_log_node_cache::init (uint32_t max_num_avail_nodes) {
m_max_num_avail = max_num_avail_nodes; m_max_num_avail = max_num_avail_nodes;
m_first = 0; m_first = 0;
m_num_avail = 0; m_num_avail = 0;
pthread_mutexattr_t attr; m_mutex = TOKU_ADAPTIVE_MUTEX_INITIALIZER;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
toku_mutex_init(&m_mutex, &attr);
} }
void rollback_log_node_cache::destroy() { void rollback_log_node_cache::destroy() {
......
...@@ -38,25 +38,34 @@ typedef struct toku_mutex { ...@@ -38,25 +38,34 @@ typedef struct toku_mutex {
} toku_mutex_t; } toku_mutex_t;
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
# define TOKU_MUTEX_ADAPTIVE PTHREAD_MUTEX_ADAPTIVE_NP
static const toku_mutex_t ZERO_MUTEX_INITIALIZER = {0}; static const toku_mutex_t ZERO_MUTEX_INITIALIZER = {0};
# if TOKU_PTHREAD_DEBUG # if TOKU_PTHREAD_DEBUG
static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER, .owner = 0, .locked = false, .valid = true }; static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER, .owner = 0, .locked = false, .valid = true };
static const toku_mutex_t TOKU_ADAPTIVE_MUTEX_INITIALIZER = { .pmutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP, .owner = 0, .locked = false, .valid = true };
# else # else
static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER }; static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER };
static const toku_mutex_t TOKU_ADAPTIVE_MUTEX_INITIALIZER = { .pmutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP };
# endif # endif
#elif defined(__APPLE__) #elif defined(__APPLE__)
# define TOKU_MUTEX_ADAPTIVE PTHREAD_MUTEX_DEFAULT
static const toku_mutex_t ZERO_MUTEX_INITIALIZER = {{0}}; static const toku_mutex_t ZERO_MUTEX_INITIALIZER = {{0}};
# if TOKU_PTHREAD_DEBUG # if TOKU_PTHREAD_DEBUG
static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER, .owner = 0, .locked = false, .valid = true }; static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER, .owner = 0, .locked = false, .valid = true };
static const toku_mutex_t TOKU_ADAPTIVE_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER, .owner = 0, .locked = false, .valid = true };
# else # else
static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER }; static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER };
static const toku_mutex_t TOKU_ADAPTIVE_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER };
# endif # endif
#else #else
# define TOKU_MUTEX_ADAPTIVE PTHREAD_MUTEX_ADAPTIVE_NP
static const toku_mutex_t ZERO_MUTEX_INITIALIZER = {{{0}}}; static const toku_mutex_t ZERO_MUTEX_INITIALIZER = {{{0}}};
# if TOKU_PTHREAD_DEBUG # if TOKU_PTHREAD_DEBUG
static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER, .owner = 0, .locked = false, .valid = true }; static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER, .owner = 0, .locked = false, .valid = true };
static const toku_mutex_t TOKU_ADAPTIVE_MUTEX_INITIALIZER = { .pmutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP, .owner = 0, .locked = false, .valid = true };
# else # else
static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER }; static const toku_mutex_t TOKU_MUTEX_INITIALIZER = { .pmutex = PTHREAD_MUTEX_INITIALIZER };
static const toku_mutex_t TOKU_ADAPTIVE_MUTEX_INITIALIZER = { .pmutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP };
# endif # endif
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment