Package org.gnome.glib
Class Timer
java.lang.Object
org.javagi.base.ProxyInstance
org.gnome.glib.Timer
- All Implemented Interfaces:
Proxy
GTimer records a start time, and counts microseconds elapsed since
that time.
This is done somewhat differently on different platforms, and can be
tricky to get exactly right, so GTimer provides a portable/convenient interface.
-
Constructor Summary
ConstructorsConstructorDescriptionTimer(MemorySegment address) Create a Timer proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidResumes a timer that has previously been stopped with g_timer_stop().voiddestroy()Destroys a timer, freeing associated resources.doubleelapsed(MemorySegment microseconds) If this Timer has been started but not stopped, obtains the time since the timer was started.booleanisActive()Exposes whether the timer is currently active.static Timernew_()Creates a new timer, and starts timing (i.e.voidreset()This function is useless; it's fine to call g_timer_start() on an already-started timer to reset the start time, so g_timer_reset() serves no purpose.voidstart()Marks a start time, so that future calls to g_timer_elapsed() will report the time since g_timer_start() was called.voidstop()Marks an end time, so calls to g_timer_elapsed() will return the difference between this end time and the start time.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Timer
Create a Timer proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
-
Method Details
-
new_
Creates a new timer, and starts timing (i.e. g_timer_start() is implicitly called for you).- Returns:
- a new
GTimer.
-
continue_
public void continue_()Resumes a timer that has previously been stopped with g_timer_stop(). g_timer_stop() must be called before using this function.- Since:
- 2.4
-
destroy
public void destroy()Destroys a timer, freeing associated resources. -
elapsed
If this Timer has been started but not stopped, obtains the time since the timer was started. If this Timer has been stopped, obtains the elapsed time between the time it was started and the time it was stopped. The return value is the number of seconds elapsed, including any fractional part. Themicrosecondsout parameter is essentially useless.- Parameters:
microseconds- return location for the fractional part of seconds elapsed, in microseconds (that is, the total number of microseconds elapsed, modulo 1000000), ornull- Returns:
- seconds elapsed as a floating point value, including any fractional part.
-
isActive
public boolean isActive()Exposes whether the timer is currently active.- Returns:
trueif the timer is running,falseotherwise- Since:
- 2.62
-
reset
public void reset()This function is useless; it's fine to call g_timer_start() on an already-started timer to reset the start time, so g_timer_reset() serves no purpose. -
start
public void start()Marks a start time, so that future calls to g_timer_elapsed() will report the time since g_timer_start() was called. g_timer_new() automatically marks the start time, so no need to call g_timer_start() immediately after creating the timer. -
stop
public void stop()Marks an end time, so calls to g_timer_elapsed() will return the difference between this end time and the start time.
-