diff options
author | Eliot Horowitz <eliot@10gen.com> | 2012-04-18 21:54:47 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2012-04-18 21:54:47 -0400 |
commit | e17e230ac042859819d0ba08bc7f68333fb1ec37 (patch) | |
tree | 444fe81ba360fe35efd1264c47da2e3d46cc445a /src/mongo/db/client.h | |
parent | 349d959379e8dd7fc039d3bc15e3757b93a9a500 (diff) | |
download | mongo-e17e230ac042859819d0ba08bc7f68333fb1ec37.tar.gz |
some cleaning of get rid of writelock for Lock::GlobalWrite and Lock::DBWrite
Diffstat (limited to 'src/mongo/db/client.h')
-rw-r--r-- | src/mongo/db/client.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h index d3f35a4d38c..2fa7cc677d7 100644 --- a/src/mongo/db/client.h +++ b/src/mongo/db/client.h @@ -166,7 +166,7 @@ namespace mongo { }; //static void assureDatabaseIsOpen(const string& ns, string path=dbpath); - + /** "read lock, and set my context, all in one operation" * This handles (if not recursively locked) opening an unopened database. */ @@ -179,16 +179,6 @@ namespace mongo { scoped_ptr<Context> c; }; - class WriteContext : boost::noncopyable { - public: - WriteContext(const string& ns, string path=dbpath, bool doauth=true ); - Context& ctx() { return *c.get(); } - private: - Lock::DBWrite lk; - scoped_ptr<Context> c; - - }; - /* Set database we want to use, then, restores when we finish (are out of scope) Note this is also helpful if an exception happens as the state if fixed up. */ @@ -247,8 +237,19 @@ namespace mongo { Database * _db; }; // class Client::Context + class WriteContext : boost::noncopyable { + public: + WriteContext(const string& ns, string path=dbpath, bool doauth=true ); + Context& ctx() { return _c; } + private: + Lock::DBWrite _lk; + Context _c; + }; + + }; // class Client + /** get the Client object for this thread. */ inline Client& cc() { Client * c = currentClient.get(); |