Commit 12803248 authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

refs #5351 do not use the static initializer in a dynamic context, because it...

refs #5351 do not use the static initializer in a dynamic context, because it confuses tools like helgrind which look for create/destroy pairs to validate mutex handling


git-svn-id: file:///svn/toku/tokudb@49865 c7de825b-a66e-492c-adef-691d508d4ae1
parent a67344b3
...@@ -15,7 +15,7 @@ void rollback_log_node_cache::init (uint32_t max_num_avail_nodes) { ...@@ -15,7 +15,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;
m_mutex = TOKU_ADAPTIVE_MUTEX_INITIALIZER; toku_adaptive_mutex_init(&m_mutex);
} }
void rollback_log_node_cache::destroy() { void rollback_log_node_cache::destroy() {
......
...@@ -20,7 +20,7 @@ void treenode::init(comparator *cmp) { ...@@ -20,7 +20,7 @@ void treenode::init(comparator *cmp) {
// use an adaptive mutex at each node since we expect the time the // use an adaptive mutex at each node since we expect the time the
// lock is held to be relatively short compared to a context switch. // lock is held to be relatively short compared to a context switch.
// indeed, this improves performance at high thread counts considerably. // indeed, this improves performance at high thread counts considerably.
m_mutex = TOKU_ADAPTIVE_MUTEX_INITIALIZER; toku_adaptive_mutex_init(&m_mutex);
m_left_child.set(nullptr); m_left_child.set(nullptr);
m_right_child.set(nullptr); m_right_child.set(nullptr);
} }
......
...@@ -85,6 +85,14 @@ toku_mutex_init(toku_mutex_t *mutex, const toku_pthread_mutexattr_t *attr) { ...@@ -85,6 +85,14 @@ toku_mutex_init(toku_mutex_t *mutex, const toku_pthread_mutexattr_t *attr) {
#endif #endif
} }
static inline void
toku_adaptive_mutex_init(toku_mutex_t *mutex) {
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
toku_mutex_init(mutex, &attr);
}
static inline void static inline void
toku_mutex_destroy(toku_mutex_t *mutex) { toku_mutex_destroy(toku_mutex_t *mutex) {
#if TOKU_PTHREAD_DEBUG #if TOKU_PTHREAD_DEBUG
......
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