summaryrefslogtreecommitdiff
path: root/libs/binder/Utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/binder/Utils.h')
-rw-r--r--libs/binder/Utils.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/libs/binder/Utils.h b/libs/binder/Utils.h
index df8a4ce1f1..5e1012af01 100644
--- a/libs/binder/Utils.h
+++ b/libs/binder/Utils.h
@@ -18,6 +18,7 @@
#include <stddef.h>
#include <sys/uio.h>
+#include <chrono>
#include <cstdint>
#include <optional>
@@ -114,4 +115,10 @@ struct Span {
// Android is little-endian.
LIBBINDER_INTERNAL_EXPORTED std::string HexString(const void* bytes, size_t len);
+// Converts any std::chrono duration to the number of milliseconds
+template <class Rep, class Period>
+uint64_t to_ms(std::chrono::duration<Rep, Period> duration) {
+ return std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
+}
+
} // namespace android