[Libreoffice-commits] core.git: cppuhelper/source include/osl include/salhelper
Stephan Bergmann
sbergman at redhat.com
Mon Aug 17 08:37:44 PDT 2015
cppuhelper/source/bootstrap.cxx | 4 +--
include/osl/time.h | 45 ++++++++++++++++++++++++++++++++++++----
include/salhelper/timer.hxx | 6 +----
3 files changed, 45 insertions(+), 10 deletions(-)
New commits:
commit b190574b6a0de3e26c6338324f74440ec0505bfb
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Mar 26 11:44:57 2015 +0100
tdf#84323: Make osl::Thread::wait more readable
Change-Id: I33eb6970050a103404344c7f16dd33349c154347
Reviewed-on: https://gerrit.libreoffice.org/15018
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
Tested-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx
index 34dd060..8d381c0 100644
--- a/cppuhelper/source/bootstrap.cxx
+++ b/cppuhelper/source/bootstrap.cxx
@@ -19,6 +19,7 @@
#include <sal/config.h>
+#include <chrono>
#include <cstring>
#include <rtl/process.h>
@@ -211,8 +212,7 @@ Reference< XComponentContext > SAL_CALL bootstrap()
catch ( connection::NoConnectException & )
{
// wait 500 ms, then try to connect again
- TimeValue tv = { 0 /* secs */, 500000000 /* nanosecs */ };
- ::osl::Thread::wait( tv );
+ ::osl::Thread::wait( std::chrono::milliseconds(500) );
}
}
}
diff --git a/include/osl/time.h b/include/osl/time.h
index 335f552..44f9af8 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 */
diff --git a/include/salhelper/timer.hxx b/include/salhelper/timer.hxx
index ac2a523..05b9556 100644
--- a/include/salhelper/timer.hxx
+++ b/include/salhelper/timer.hxx
@@ -56,11 +56,9 @@ struct TTimeValue : public TimeValue
normalize();
}
- TTimeValue( const TTimeValue& rTimeValue )
+ TTimeValue( const TTimeValue& rTimeValue ):
+ TimeValue(rTimeValue)
{
- Seconds = rTimeValue.Seconds;
- Nanosec = rTimeValue.Nanosec;
-
normalize();
}
More information about the Libreoffice-commits
mailing list