summaryrefslogtreecommitdiff
path: root/src/mongo/db/client.h
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-11-06 22:18:15 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-11-13 14:30:10 -0500
commit284f942a45b877f0baecd19cbf17fc2a4e246a79 (patch)
tree1ab1c86450338fe7f5b7276cb3a35b092b61bc93 /src/mongo/db/client.h
parent1722a1f3ec981d2e6c3478685e527a34f9863f2e (diff)
downloadmongo-284f942a45b877f0baecd19cbf17fc2a4e246a79.tar.gz
SERVER-14062 Cleanup Client::hasWrittenSinceCheckpoint and some usages of cc()
This is in preparation for removing the Global OperationContext registry. OperationContexts will instead be reachable through the client.
Diffstat (limited to 'src/mongo/db/client.h')
-rw-r--r--src/mongo/db/client.h50
1 files changed, 27 insertions, 23 deletions
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index 78696268ff3..5fe44c85b09 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -36,17 +36,19 @@
#pragma once
+#include <boost/thread/thread.hpp>
+
#include "mongo/db/catalog/database.h"
#include "mongo/db/client_basic.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/lasterror.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
+#include "mongo/platform/unordered_set.h"
#include "mongo/stdx/functional.h"
#include "mongo/util/concurrency/threadlocal.h"
#include "mongo/util/paths.h"
-
namespace mongo {
class AuthenticationInfo;
@@ -152,12 +154,14 @@ namespace mongo {
Collection* _coll;
};
+ typedef unordered_set<Client*> ClientSet;
+
/** the database's concept of an outside "client" */
class Client : public ClientBasic {
public:
- // always be in clientsMutex when manipulating this. killop stuff uses these.
- static std::set<Client*>& clients;
- static mongo::mutex& clientsMutex;
+ // A set of currently active clients along with a mutex to protect the list
+ static boost::mutex clientsMutex;
+ static ClientSet clients;
~Client();
@@ -207,33 +211,33 @@ namespace mongo {
void setRemoteID(const OID& rid) { _remoteId = rid; } // Only used for master/slave
OID getRemoteID() const { return _remoteId; } // Only used for master/slave
ConnectionId getConnectionId() const { return _connectionId; }
- const std::string& getThreadId() const { return _threadId; }
-
- // XXX(hk): this is per-thread mmapv1 recovery unit stuff, move into that
- // impl of recovery unit
- void writeHappened() { _hasWrittenSinceCheckpoint = true; }
- bool hasWrittenSinceCheckpoint() const { return _hasWrittenSinceCheckpoint; }
- void checkpointHappened() { _hasWrittenSinceCheckpoint = false; }
-
- // XXX: this is really a method in the recovery unit iface to reset any state
- void newTopLevelRequest() {
- _hasWrittenSinceCheckpoint = false;
- }
private:
Client(const std::string& desc, AbstractMessagingPort *p = 0);
friend class CurOp;
- ConnectionId _connectionId; // > 0 for things "conn", 0 otherwise
- std::string _threadId; // "" on non support systems
- CurOp * _curOp;
- bool _shutdown; // to track if Client::shutdown() gets called
- std::string _desc;
+
+ // Description for the client (e.g. conn8)
+ const std::string _desc;
+
+ // OS id of the thread, which owns this client
+ const boost::thread::id _threadId;
+
+ // > 0 for things "conn", 0 otherwise
+ const ConnectionId _connectionId;
+
+ // Whether this client is running as DBDirectClient
bool _god;
+
+ // Changes, based on what operation is running. Some of this should be in OperationContext.
+ CurOp* _curOp;
+
+ // Used by replication
OpTime _lastOp;
OID _remoteId; // Only used by master-slave
- bool _hasWrittenSinceCheckpoint;
-
+ // Tracks if Client::shutdown() gets called (TODO: Is this necessary?)
+ bool _shutdown;
+
public:
/* Set database we want to use, then, restores when we finish (are out of scope)