summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2011-10-10 00:44:15 -0400
committerEliot Horowitz <eliot@10gen.com>2011-10-10 00:44:15 -0400
commita7a36ecbf060624a1bfcf36e0a00de02b907c019 (patch)
tree37f12f4d46e126cd62a4034a99cd5dde59bebfb0
parent417b9110cecf0bd7aad7e0102d104b45b28c40dc (diff)
downloadmongo-a7a36ecbf060624a1bfcf36e0a00de02b907c019.tar.gz
use SpinLock for DiagStr
-rw-r--r--util/concurrency/value.h13
-rw-r--r--util/concurrency/vars.cpp2
2 files changed, 7 insertions, 8 deletions
diff --git a/util/concurrency/value.h b/util/concurrency/value.h
index 35564d1cd13..897fa95af1e 100644
--- a/util/concurrency/value.h
+++ b/util/concurrency/value.h
@@ -21,6 +21,7 @@
#pragma once
#include "mutex.h"
+#include "spin_lock.h"
namespace mongo {
@@ -47,31 +48,31 @@ namespace mongo {
class DiagStr {
string _s;
- static SimpleMutex m;
+ mutable SpinLock m;
public:
DiagStr(const DiagStr& r) : _s(r.get()) { }
DiagStr() { }
bool empty() const {
- SimpleMutex::scoped_lock lk(m);
+ scoped_spinlock lk(m);
return _s.empty();
}
string get() const {
- SimpleMutex::scoped_lock lk(m);
+ scoped_spinlock lk(m);
return _s;
}
void set(const char *s) {
- SimpleMutex::scoped_lock lk(m);
+ scoped_spinlock lk(m);
_s = s;
}
void set(const string& s) {
- SimpleMutex::scoped_lock lk(m);
+ scoped_spinlock lk(m);
_s = s;
}
operator string() const { return get(); }
void operator=(const string& s) { set(s); }
void operator=(const DiagStr& rhs) {
- SimpleMutex::scoped_lock lk(m);
+ scoped_spinlock lk(m);
_s = rhs.get();
}
};
diff --git a/util/concurrency/vars.cpp b/util/concurrency/vars.cpp
index 669725a1492..b561ccce003 100644
--- a/util/concurrency/vars.cpp
+++ b/util/concurrency/vars.cpp
@@ -22,8 +22,6 @@
namespace mongo {
- SimpleMutex DiagStr::m("diags");
-
// intentional leak. otherwise destructor orders can be problematic at termination.
MutexDebugger &mutexDebugger = *(new MutexDebugger());