Skip to content

Commit faab4aa

Browse files
author
MarcoFalke
committed
util: Add count_microseconds helper
1 parent 62948ca commit faab4aa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/util/time.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ void UninterruptibleSleep(const std::chrono::microseconds& n);
1515
/**
1616
* Helper to count the seconds of a duration.
1717
*
18-
* All durations should be using std::chrono and calling this should generally be avoided in code. Though, it is still
19-
* preferred to an inline t.count() to protect against a reliance on the exact type of t.
18+
* All durations should be using std::chrono and calling this should generally
19+
* be avoided in code. Though, it is still preferred to an inline t.count() to
20+
* protect against a reliance on the exact type of t.
21+
*
22+
* This helper is used to convert durations before passing them over an
23+
* interface that doesn't support std::chrono (e.g. RPC, debug log, or the GUI)
2024
*/
2125
inline int64_t count_seconds(std::chrono::seconds t) { return t.count(); }
26+
inline int64_t count_microseconds(std::chrono::microseconds t) { return t.count(); }
2227

2328
/**
2429
* DEPRECATED

0 commit comments

Comments
 (0)