Commit 5a606441 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

refs #5351 fix mutexattr stuff for darwin

git-svn-id: file:///svn/toku/tokudb@49885 c7de825b-a66e-492c-adef-691d508d4ae1
parent 72fbfa3e
......@@ -15,7 +15,11 @@ void rollback_log_node_cache::init (uint32_t max_num_avail_nodes) {
m_max_num_avail = max_num_avail_nodes;
m_first = 0;
m_num_avail = 0;
toku_adaptive_mutex_init(&m_mutex);
toku_pthread_mutexattr_t attr;
toku_mutexattr_init(&attr);
toku_mutexattr_settype(&attr, TOKU_MUTEX_ADAPTIVE);
toku_mutex_init(&m_mutex, &attr);
toku_mutexattr_destroy(&attr);
}
void rollback_log_node_cache::destroy() {
......
......@@ -20,7 +20,11 @@ void treenode::init(comparator *cmp) {
// 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.
// indeed, this improves performance at high thread counts considerably.
toku_adaptive_mutex_init(&m_mutex);
toku_pthread_mutexattr_t attr;
toku_mutexattr_init(&attr);
toku_mutexattr_settype(&attr, TOKU_MUTEX_ADAPTIVE);
toku_mutex_init(&m_mutex, &attr);
toku_mutexattr_destroy(&attr);
m_left_child.set(nullptr);
m_right_child.set(nullptr);
}
......
......@@ -86,11 +86,21 @@ toku_mutex_init(toku_mutex_t *mutex, const toku_pthread_mutexattr_t *attr) {
}
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);
toku_mutexattr_init(toku_pthread_mutexattr_t *attr) {
int r = pthread_mutexattr_init(attr);
assert_zero(r);
}
static inline void
toku_mutexattr_settype(toku_pthread_mutexattr_t *attr, int type) {
int r = pthread_mutexattr_settype(attr, type);
assert_zero(r);
}
static inline void
toku_mutexattr_destroy(toku_pthread_mutexattr_t *attr) {
int r = pthread_mutexattr_destroy(attr);
assert_zero(r);
}
static inline void
......
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