aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/os/Platform.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-06 10:28:32 +0100
committerSven Gothel <[email protected]>2023-03-06 10:28:32 +0100
commit717bc406e96fbff30cf02adad019cf9daa14e59c (patch)
tree110022593c156d9e339e4e5fdb726e2e08049279 /src/java/com/jogamp/common/os/Platform.java
parent69b748925038b7d44fa6318536642b426e3d3e38 (diff)
Add Clock, implementing proper monotonic and wallclock time using Instant (sec + nsec), currentTimeMillis() is also monotonic now, reused by Platform. Dropped Platform.currentTimeMicros()
Clock and its implementation was copied from jaulibs, a spin-off from Direct-BT. The implementation uses `clock_gettime(CLOCK_MONOTONIC, &t)` and is considered safe and high-performant as it avoids a kernel call via VDSO (GNU/Linux).
Diffstat (limited to 'src/java/com/jogamp/common/os/Platform.java')
-rw-r--r--src/java/com/jogamp/common/os/Platform.java26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java
index e6821ba..9c65596 100644
--- a/src/java/com/jogamp/common/os/Platform.java
+++ b/src/java/com/jogamp/common/os/Platform.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright 2010-2023 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
@@ -521,26 +521,12 @@ public class Platform extends PlatformPropsImpl {
//
/**
- * Returns the unix based current time in milliseconds, based on <code>gettimeofday(..)</code>.
- * <p>
- * This is an alternative to {@link System#currentTimeMillis()} and {@link System#nanoTime()}.
- * While the named {@link System} methods do provide the required precision,
- * <code>gettimeofday()</code> <i>also</i> guarantees time accuracy, i.e. update interval.
- * </p>
- * @see #currentTimeMicros()
- */
- public static native long currentTimeMillis();
-
- /**
- * Returns the unix based current time in microseconds, based on <code>gettimeofday(..)</code>.
- * <p>
- * This is an alternative to {@link System#currentTimeMillis()} and {@link System#nanoTime()}.
- * While the named {@link System} methods do provide the required precision,
- * <code>gettimeofday()</code> <i>also</i> guarantees time accuracy, i.e. update interval.
- * </p>
- * @see #currentTimeMillis()
+ * Returns the unix based current time in milliseconds, see {@link Clock#currentTimeMillis()}.
+ * @see Clock#currentTimeMillis()
*/
- public static native long currentTimeMicros();
+ public static long currentTimeMillis() {
+ return Clock.currentTimeMillis();
+ }
/**
* Returns the estimated sleep jitter value in nanoseconds.