summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-07-31 13:37:32 -0400
committerDwight <dmerriman@gmail.com>2008-07-31 13:37:32 -0400
commit234844724cfeb7635073d08e5229bcb521d961e2 (patch)
tree9e128b9e9ba58a1247efe8d0b7d24ea418c0b89e /util
parent74337a4d3c01b93623049a2766532bb0b5e29e79 (diff)
downloadmongo-234844724cfeb7635073d08e5229bcb521d961e2.tar.gz
checkpoitning work
Diffstat (limited to 'util')
-rw-r--r--util/goodies.h27
-rw-r--r--util/log.h8
2 files changed, 30 insertions, 5 deletions
diff --git a/util/goodies.h b/util/goodies.h
index 43139d9c4a9..282f96694d0 100644
--- a/util/goodies.h
+++ b/util/goodies.h
@@ -162,7 +162,7 @@ inline unsigned curTimeMicros() {
return t;
}
using namespace boost;
-typedef boost::mutex::scoped_lock lock;
+typedef boost::mutex::scoped_lock boostlock;
// simple scoped timer
class Timer {
@@ -176,3 +176,28 @@ public:
private:
unsigned old;
};
+
+/*
+
+class DebugMutex : boost::noncopyable {
+ friend class lock;
+ boost::mutex m;
+ int locked;
+public:
+ DebugMutex() : locked(0); { }
+ bool isLocked() { return locked; }
+};
+
+*/
+/*
+struct lock {
+boostlock bl;
+ DebugMutex& m;
+ lock(DebugMutex& _m) : m(_m) {
+ do_lock();
+ }
+ ~lock() { do_unlock(); }
+}
+*/
+typedef boostlock lock;
+
diff --git a/util/log.h b/util/log.h
index 78be6e28b1b..61ac66a931b 100644
--- a/util/log.h
+++ b/util/log.h
@@ -35,7 +35,7 @@ public:
inline Nullstream& endl ( Nullstream& os ) { }
extern Nullstream nullstream;
-#define LOGIT { lock lk(mutex); cout << x; return *this; }
+#define LOGIT { boostlock lk(mutex); cout << x; return *this; }
class Logstream {
static boost::mutex mutex;
public:
@@ -49,10 +49,10 @@ public:
Logstream& operator<<(long long x) LOGIT
Logstream& operator<<(unsigned long long x) LOGIT
Logstream& operator<<(const string& x) LOGIT
- Logstream& operator<< (ostream& ( *_endl )(ostream&)) { lock lk(mutex); cout << _endl; return *this; }
- Logstream& operator<< (ios_base& (*_hex)(ios_base&)) { lock lk(mutex); cout << _hex; return *this; }
+ Logstream& operator<< (ostream& ( *_endl )(ostream&)) { boostlock lk(mutex); cout << _endl; return *this; }
+ Logstream& operator<< (ios_base& (*_hex)(ios_base&)) { boostlock lk(mutex); cout << _hex; return *this; }
Logstream& prolog(bool withNs = false) {
- lock lk(mutex);
+ boostlock lk(mutex);
time_t t;
time(&t);
string now(ctime(&t),0,20);