summaryrefslogtreecommitdiff
path: root/include/osl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-03-26 11:44:57 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-08-17 15:37:22 +0000
commitb190574b6a0de3e26c6338324f74440ec0505bfb (patch)
tree04ce4fa3231bf32e7bbf7b2fe51409e5113d25ea /include/osl
parent3c2b80066bf2fba4e7222fb7d30ac7d412539818 (diff)
tdf#84323: Make osl::Thread::wait more readable
Change-Id: I33eb6970050a103404344c7f16dd33349c154347 Reviewed-on: https://gerrit.libreoffice.org/15018 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/osl')
-rw-r--r--include/osl/time.h45
1 files changed, 41 insertions, 4 deletions
diff --git a/include/osl/time.h b/include/osl/time.h
index 335f552e7467..44f9af817759 100644
--- a/include/osl/time.h
+++ b/include/osl/time.h
@@ -22,13 +22,13 @@
#include <sal/config.h>
+#if defined LIBO_INTERNAL_ONLY && defined __cplusplus
+#include <chrono>
+#endif
+
#include <sal/saldllapi.h>
#include <sal/types.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/****************************************************************************/
/* TimeValue */
/****************************************************************************/
@@ -39,15 +39,52 @@ extern "C" {
/* Time since Jan-01-1970 */
+#if defined LIBO_INTERNAL_ONLY && defined __cplusplus
+
+struct TimeValue {
+ TimeValue() = default;
+
+ SAL_CONSTEXPR TimeValue(sal_uInt32 seconds, sal_uInt32 nanoseconds):
+ Seconds(seconds), Nanosec(nanoseconds) {}
+
+ template<typename Rep, typename Period> SAL_CONSTEXPR
+ TimeValue(std::chrono::duration<Rep, Period> const & duration):
+ Seconds(
+ std::chrono::duration_cast<std::chrono::nanoseconds>(
+ duration).count() / 1000000000),
+ Nanosec(
+ std::chrono::duration_cast<std::chrono::nanoseconds>(
+ duration).count() % 1000000000)
+ {}
+
+ sal_uInt32 Seconds;
+ sal_uInt32 Nanosec;
+};
+
+#else
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct {
sal_uInt32 Seconds;
sal_uInt32 Nanosec;
} TimeValue;
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
#if defined(SAL_W32)
# pragma pack(pop)
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
/****************************************************************************/
/* oslDateTime */