/Users/deen/code/yugabyte-db/src/yb/util/debug/long_operation_tracker.h
Line | Count | Source |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_UTIL_DEBUG_LONG_OPERATION_TRACKER_H |
15 | | #define YB_UTIL_DEBUG_LONG_OPERATION_TRACKER_H |
16 | | |
17 | | #include <memory> |
18 | | |
19 | | #include "yb/util/monotime.h" |
20 | | |
21 | | namespace yb { |
22 | | |
23 | | // Tracks long running operation. |
24 | | // If it does not complete within specified duration warning is added to log. |
25 | | // Warning contains stack trace of thread that created this tracker. |
26 | | class LongOperationTracker { |
27 | | public: |
28 | 12.5M | LongOperationTracker() = default; |
29 | | LongOperationTracker(const char* message, MonoDelta duration); |
30 | | ~LongOperationTracker(); |
31 | | |
32 | | LongOperationTracker(const LongOperationTracker&) = delete; |
33 | | void operator=(const LongOperationTracker&) = delete; |
34 | | |
35 | 1.75M | LongOperationTracker(LongOperationTracker&&) = default; |
36 | 3.48M | LongOperationTracker& operator=(LongOperationTracker&&) = default; |
37 | | |
38 | | struct TrackedOperation; |
39 | | |
40 | | private: |
41 | | std::shared_ptr<TrackedOperation> tracked_operation_; |
42 | | }; |
43 | | |
44 | | } // namespace yb |
45 | | |
46 | | #endif // YB_UTIL_DEBUG_LONG_OPERATION_TRACKER_H |