public final class Native extends Object
The driver can benefit from native system calls to improve its performance and accuracy in some situations.
Currently, the following features may be used by the driver when available:
currentTimeMicros()
: thanks to a system call to gettimeofday()
, the driver
is able to generate timestamps with true microsecond precision (see AtomicMonotonicTimestampGenerator
or ThreadLocalMonotonicTimestampGenerator
for
more information);
processId()
: thanks to a system call to getpid()
, the driver has access to
the JVM's process ID it is running under – which makes time-based UUID generation easier
and more reliable (see UUIDs
for more
information).
The availability of the aforementioned system calls depends on the underlying operation
system's capabilities. For instance, gettimeofday()
is not available under Windows
systems. You can check if any of the system calls exposed through this class is available by
calling isGettimeofdayAvailable()
or isGetpidAvailable()
.
Note: This class is public because it needs to be accessible from other packages of the Java driver, but it is not meant to be used directly by client code.
Constructor and Description |
---|
Native() |
Modifier and Type | Method and Description |
---|---|
static long |
currentTimeMicros()
Returns the current timestamp with microsecond precision via a system call to
gettimeofday , through JNR C library. |
static boolean |
isGetpidAvailable()
Returns
true if JNR POSIX library is loaded and a call to getpid is possible
through this library on this system, and false otherwise. |
static boolean |
isGettimeofdayAvailable()
Returns
true if JNR C library is loaded and a call to gettimeofday is possible
through this library on this system, and false otherwise. |
static int |
processId()
Returns the JVM's process identifier (PID) via a system call to
getpid . |
public static boolean isGettimeofdayAvailable()
true
if JNR C library is loaded and a call to gettimeofday
is possible
through this library on this system, and false
otherwise.true
if JNR C library is loaded and a call to gettimeofday
is possible.public static boolean isGetpidAvailable()
true
if JNR POSIX library is loaded and a call to getpid
is possible
through this library on this system, and false
otherwise.true
if JNR POSIX library is loaded and a call to getpid
is possible.public static long currentTimeMicros()
gettimeofday
, through JNR C library.UnsupportedOperationException
- if JNR C library is not loaded or gettimeofday
is
not available.IllegalStateException
- if the call to gettimeofday
did not complete with return
code 0.public static int processId()
getpid
.UnsupportedOperationException
- if JNR POSIX library is not loaded or getpid
is
not available.Copyright © 2012–2020. All rights reserved.