summaryrefslogtreecommitdiff
path: root/src/mongo/db/clientcursor.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-08-26 17:58:00 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2014-08-27 10:49:14 -0400
commitc069fc13a91204940c82a90f7c2c2f09b80c3428 (patch)
tree9092ff3c0695c2c7cedb309f334951b3f97d7930 /src/mongo/db/clientcursor.cpp
parent32643343be6e0100a887dae4a44d33f710dfd086 (diff)
downloadmongo-c069fc13a91204940c82a90f7c2c2f09b80c3428.tar.gz
SERVER-14668 Remove d_globals.h/.cpp
They were only used for ClientCursorMonitor startup, so I moved this to be a singleton task.
Diffstat (limited to 'src/mongo/db/clientcursor.cpp')
-rw-r--r--src/mongo/db/clientcursor.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index df7d55f419b..c005376730f 100644
--- a/src/mongo/db/clientcursor.cpp
+++ b/src/mongo/db/clientcursor.cpp
@@ -222,23 +222,32 @@ namespace mongo {
// ClientCursorMonitor
//
- void ClientCursorMonitor::run() {
- Client::initThread("clientcursormon");
- Client& client = cc();
- Timer t;
- const int Secs = 4;
- while (!inShutdown()) {
- OperationContextImpl txn;
- cursorStatsTimedOut.increment(
- CollectionCursorCache::timeoutCursorsGlobal(&txn, t.millisReset()));
- sleepsecs(Secs);
+ /**
+ * Thread for timing out old cursors
+ */
+ class ClientCursorMonitor : public BackgroundJob {
+ public:
+ std::string name() const { return "ClientCursorMonitor"; }
+
+ void run() {
+ Client::initThread("clientcursormon");
+ Client& client = cc();
+ Timer t;
+ const int Secs = 4;
+ while (!inShutdown()) {
+ OperationContextImpl txn;
+ cursorStatsTimedOut.increment(
+ CollectionCursorCache::timeoutCursorsGlobal(&txn, t.millisReset()));
+ sleepsecs(Secs);
+ }
+ client.shutdown();
}
- client.shutdown();
- }
+ };
namespace {
- ClientCursorMonitor clientCursorMonitor;
-
+ // Only one instance of the ClientCursorMonitor exists
+ ClientCursorMonitor clientCursorMonitor = ClientCursorMonitor();
+
void _appendCursorStats( BSONObjBuilder& b ) {
b.append( "note" , "deprecated, use server status metrics" );
b.appendNumber("clientCursors_size", cursorStatsOpen.get() );
@@ -249,6 +258,10 @@ namespace mongo {
}
}
+ void startClientCursorMonitor() {
+ clientCursorMonitor.go();
+ }
+
// QUESTION: Restrict to the namespace from which this command was issued?
// Alternatively, make this command admin-only?
// TODO: remove this for 2.8