forked from Expensify/Bedrock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBedrockCommand.h
More file actions
74 lines (56 loc) · 2.07 KB
/
BedrockCommand.h
File metadata and controls
74 lines (56 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
#include <sqlitecluster/SQLiteCommand.h>
class BedrockCommand : public SQLiteCommand {
public:
enum Priority {
PRIORITY_MIN = 0,
PRIORITY_LOW = 250,
PRIORITY_NORMAL = 500,
PRIORITY_HIGH = 750,
PRIORITY_MAX = 1000
};
enum TIMING_INFO {
INVALID,
PEEK,
PROCESS,
COMMIT_WORKER,
COMMIT_SYNC,
QUEUE_WORKER,
QUEUE_SYNC,
};
// Constructor to make an empty object.
BedrockCommand();
// Constructor to convert from an existing SQLiteCommand (by move).
BedrockCommand(SQLiteCommand&& from);
// Move constructor.
BedrockCommand(BedrockCommand&& from);
// Constructor to initialize via a request object (by move).
BedrockCommand(SData&& _request);
// Constructor to initialize via a request object (by copy).
BedrockCommand(SData _request);
// Destructor.
~BedrockCommand();
// Move assignment operator.
BedrockCommand& operator=(BedrockCommand&& from);
// Start recording time for a given action type.
void startTiming(TIMING_INFO type);
// Finish recording time for a given action type. `type` must match what was passed to the most recent call to
// `startTiming`.
void stopTiming(TIMING_INFO type);
// Add a summary of our timing info to our response object.
void finalizeTimingInfo();
// If the `peek` portion of this command needs to make an HTTPS request, this is where we store it.
SHTTPSManager::Transaction* httpsRequest;
// Each command is assigned a priority.
Priority priority;
// We track how many times we `peek` and `process` each command.
int peekCount;
int processCount;
// A list of timing sets, with an info type, start, and end.
list<tuple<TIMING_INFO, uint64_t, uint64_t>> timingInfo;
private:
// Set certain initial state on construction. Common functionality to several constructors.
void _init();
// used as a temporary variable for startTiming and stopTiming.
tuple<TIMING_INFO, uint64_t, uint64_t> _inProgressTiming;
};