We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 87d6447 commit d4901afCopy full SHA for d4901af
src/common/ceph_time.h
@@ -342,6 +342,23 @@ class coarse_mono_clock {
342
}
343
};
344
345
+// Please note time_guard is not thread safety -- multiple threads
346
+// updating same diff_accumulator can corrupt it.
347
+template <class ClockT = mono_clock>
348
+class time_guard {
349
+ const typename ClockT::time_point start;
350
+ timespan& diff_accumulator;
351
+
352
+public:
353
+ time_guard(timespan& diff_accumulator)
354
+ : start(ClockT::now()),
355
+ diff_accumulator(diff_accumulator) {
356
+ }
357
+ ~time_guard() {
358
+ diff_accumulator += ClockT::now() - start;
359
360
+};
361
362
namespace time_detail {
363
// So that our subtractions produce negative spans rather than
364
// arithmetic underflow.
0 commit comments