public class DiscreteClock extends Clock
Vona's utils: a discrete clock.
Copyright (C) 2004 Marsette A. Vona, III
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String |
cvsid
CVS id.
|
static double |
SLEEP_GRANULARITY
Real-world sleep granularity, see
CompatTime.getSleepGranularity() . |
protected double |
time
the current time
|
Constructor and Description |
---|
DiscreteClock() |
Modifier and Type | Method and Description |
---|---|
double |
getCurrentTime()
Get the time in seconds.
|
void |
setTime(double time)
Set the current time to the specified value.
|
void |
sleep(double seconds)
Sleep the current thread until this clock's time is greater than or
equal to its current value plus the specified sleep.
|
void |
tick(double increment)
Increment the current time by the specified value.
|
periodicThreadEnding, periodicThreadStarting
static final java.lang.String cvsid
CVS id.
public static final double SLEEP_GRANULARITY
Real-world sleep granularity, see CompatTime.getSleepGranularity()
.
protected double time
public double getCurrentTime()
Get the time in seconds.
getCurrentTime
in class Clock
public void sleep(double seconds) throws java.lang.InterruptedException
Sleep the current thread until this clock's time is greater than or equal to its current value plus the specified sleep.
Waits in (real-world time) increments of SLEEP_GRANULARITY
seconds.
public void setTime(double time)
Set the current time to the specified value.
time
- the new time in secondspublic void tick(double increment)
Increment the current time by the specified value.
increment
- the time increment in seconds