summaryrefslogtreecommitdiff
path: root/src/mongo/db/curop.h
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-05-22 15:24:52 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-05-29 10:28:03 -0400
commit4ea38c308da292f43e29d32b1b53b7324db0bafe (patch)
tree22d166a388262ae5837d0c4e44f42748194e3e47 /src/mongo/db/curop.h
parent5c2d133871b2ad2adf6c617364d036ca25261f2d (diff)
downloadmongo-4ea38c308da292f43e29d32b1b53b7324db0bafe.tar.gz
SERVER-14995 Move operation id, lockState and client fields to OperationContext.
They have been moved from OperationContextImpl. Furthermore, the CurOp stack is now attached to OperationContext, instead of Client. With this change, an operation's lifetime is governed by the lifetime of an OperationContext object. The "_active" field of CurOp is therefore no longer meaingful. This required fixing the lifetime of OperationContext in a few places. A future change will adjust operation lifetime timing to time the lifetime of the OperationContext object, as well.
Diffstat (limited to 'src/mongo/db/curop.h')
-rw-r--r--src/mongo/db/curop.h33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index 66201f53fdd..f58ee576370 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -34,7 +34,7 @@
#include <boost/noncopyable.hpp>
#include "mongo/base/disallow_copying.h"
-#include "mongo/db/client.h"
+#include "mongo/db/operation_context.h"
#include "mongo/db/server_options.h"
#include "mongo/platform/atomic_word.h"
#include "mongo/util/concurrency/spin_lock.h"
@@ -198,8 +198,7 @@ namespace mongo {
static CurOp* get(const OperationContext* opCtx);
static CurOp* get(const OperationContext& opCtx);
- explicit CurOp(Client* client);
- CurOp(Client* client, int op);
+ explicit CurOp(OperationContext* client);
~CurOp();
bool haveQuery() const { return _query.have(); }
@@ -207,8 +206,11 @@ namespace mongo {
void appendQuery( BSONObjBuilder& b , StringData name ) const { _query.append( b , name ); }
void enter(const char* ns, int dbProfileLevel);
- void reset();
- void reset(int op);
+
+ /**
+ * Sets the type of the current operation to "op".
+ */
+ void setOp(int op);
void markCommand() { _isCommand = true; }
OpDebug& debug() { return _debug; }
std::string getNS() const { return _ns.toString(); }
@@ -220,11 +222,6 @@ namespace mongo {
return _dbprofile >= 2 || ms >= serverGlobalParams.slowMS;
}
- unsigned int opNum() const { return _opNum; }
-
- /** if this op is running */
- bool active() const { return _active; }
-
int getOp() const { return _op; }
//
@@ -271,12 +268,11 @@ namespace mongo {
return _start;
}
void done() {
- _active = false;
_end = curTimeMicros64();
}
long long totalTimeMicros() {
- massert( 12601 , "CurOp not marked done yet" , ! _active );
+ massert( 12601 , "CurOp not marked done yet" , _end );
return _end - startTime();
}
int totalTimeMillis() { return (int) (totalTimeMicros() / 1000); }
@@ -321,25 +317,20 @@ namespace mongo {
void setNS( StringData ns );
private:
- class ClientCuropStack;
-
- static const Client::Decoration<ClientCuropStack> _curopStack;
+ class CurOpStack;
- CurOp(Client*, ClientCuropStack*);
+ static const OperationContext::Decoration<CurOpStack> _curopStack;
- void _reset();
+ CurOp(OperationContext*, CurOpStack*);
- static AtomicUInt32 _nextOpNum;
- ClientCuropStack* _stack;
+ CurOpStack* _stack;
CurOp* _parent = nullptr;
Command * _command;
long long _start;
long long _end;
- bool _active;
int _op;
bool _isCommand;
int _dbprofile; // 0=off, 1=slow, 2=all
- unsigned int _opNum;
ThreadSafeString _ns;
CachedBSONObj<512> _query; // CachedBSONObj is thread safe
OpDebug _debug;