Add hasPeriodPassed function to java, for parity with C++ Timer API

Change-Id: I0f9a2714f20deaaccce610bd3eec58409eac3104
This commit is contained in:
Dustin Spicuzza
2014-11-30 23:51:01 -05:00
parent b59f4141c4
commit 8e707169a1
3 changed files with 60 additions and 0 deletions

View File

@@ -113,6 +113,19 @@ public class Timer {
timer.stop();
}
/**
* Check if the period specified has passed and if it has, advance the start
* time by that period. This is useful to decide if it's time to do periodic
* work without drifting later by the time it took to get around to checking.
*
* @param period The period to check for (in seconds).
* @return If the period has passed.
*/
public boolean hasPeriodPassed(double period)
{
return timer.hasPeriodPassed(period);
}
public interface Interface {
/**
* Get the current time from the timer. If the clock is running it is derived from
@@ -143,5 +156,16 @@ public class Timer {
* looking at the system clock.
*/
public void stop();
/**
* Check if the period specified has passed and if it has, advance the start
* time by that period. This is useful to decide if it's time to do periodic
* work without drifting later by the time it took to get around to checking.
*
* @param period The period to check for (in seconds).
* @return If the period has passed.
*/
public boolean hasPeriodPassed(double period);
}
}