diff options
author | Eliot Horowitz <eliot@10gen.com> | 2012-06-12 00:49:13 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2012-06-12 01:52:26 -0400 |
commit | f58ba6e38cb3e3f62d6cbacdfd646364b005a17e (patch) | |
tree | d4268a953f11d4c2389f7a075ebf7890a02bc230 /src/mongo/db/d_concurrency.h | |
parent | ea5f7a757789ba0ddaf9dfcab4fac8ab4050ae43 (diff) | |
download | mongo-f58ba6e38cb3e3f62d6cbacdfd646364b005a17e.tar.gz |
SERVER-4328 - db and global lock and acquisition time for read and write
Diffstat (limited to 'src/mongo/db/d_concurrency.h')
-rw-r--r-- | src/mongo/db/d_concurrency.h | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/mongo/db/d_concurrency.h b/src/mongo/db/d_concurrency.h index e2d05298163..5166a606ab6 100644 --- a/src/mongo/db/d_concurrency.h +++ b/src/mongo/db/d_concurrency.h @@ -49,6 +49,9 @@ namespace mongo { static void assertWriteLocked(const StringData& ns); static bool dbLevelLockingEnabled(); + + static LockStat* globalLockStat(); + static LockStat* nestableLockStat( Nestable db ); class ScopedLock; @@ -82,14 +85,29 @@ namespace mongo { public: class ScopedLock : boost::noncopyable { - ParallelBatchWriterSupport _lk; - protected: - friend struct TempRelease; - ScopedLock(); - virtual void tempRelease() = 0; - virtual void relock() = 0; public: virtual ~ScopedLock(); + + /** @return micros since we started acquiring */ + long long acquireFinished( LockStat* stat ); + + protected: + friend struct TempRelease; + + explicit ScopedLock( char type ); + + void tempRelease(); + void relock(); + + virtual void _tempRelease() = 0; + virtual void _relock() = 0; + + ParallelBatchWriterSupport _lk; + + private: + Timer _timer; // this is counting the current state + char _type; + LockStat* _stat; // the stat for the relevant lock to increment when we're done }; // note that for these classes recursive locking is ok if the recursive locking "makes sense" @@ -98,8 +116,8 @@ namespace mongo { class GlobalWrite : public ScopedLock { bool noop; protected: - void tempRelease(); - void relock(); + void _tempRelease(); + void _relock(); public: // stopGreed is removed and does NOT work // timeoutms is only for writelocktry -- deprecated -- do not use @@ -112,8 +130,8 @@ namespace mongo { public: bool noop; protected: - void tempRelease(); - void relock(); + void _tempRelease(); + void _relock(); public: // timeoutms is only for readlocktry -- deprecated -- do not use GlobalRead( int timeoutms = -1 ); @@ -137,8 +155,8 @@ namespace mongo { void unlockDB(); protected: - void tempRelease(); - void relock(); + void _tempRelease(); + void _relock(); public: DBWrite(const StringData& dbOrNs); @@ -171,8 +189,8 @@ namespace mongo { void unlockDB(); protected: - void tempRelease(); - void relock(); + void _tempRelease(); + void _relock(); public: DBRead(const StringData& dbOrNs); |