本文整理汇总了Java中com.blockwithme.time.TimeListener类的典型用法代码示例。如果您正苦于以下问题:Java TimeListener类的具体用法?Java TimeListener怎么用?Java TimeListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimeListener类属于com.blockwithme.time包,在下文中一共展示了TimeListener类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerListener
import com.blockwithme.time.TimeListener; //导入依赖的package包/类
@Override
public Task<TimeListener> registerListener(final TimeListener listener) {
final MyTask<TimeListener> result = new MyTask<TimeListener>(listeners,
Objects.requireNonNull(listener));
listeners.add(result);
return result;
}
示例2: testPauseAndComputedRealTime
import com.blockwithme.time.TimeListener; //导入依赖的package包/类
public void testPauseAndComputedRealTime() throws Exception {
try (final ClockService impl = newClockService()) {
try (final Scheduler sched = impl.newScheduler("sched", null)) {
try (final Timeline t = impl.coreTimeline()
.newChildTimeline(false, sched).setTicksPerSecond(10)
.setLocalTickScaling(10.0).paused().create("t")) {
System.out.println(t);
final AtomicLong tLastTick = new AtomicLong();
final TimeListener tl = new TimeListener() {
@Override
public void onTimeChange(final Time tick) {
tLastTick.set(tick.runningElapsedTicks);
System.out.println("NOW: "
+ impl.clock().instant());
System.out.println("TS1: "
+ tick.runningElapsedTicks + " "
+ ((double) tick.tickDuration)
/ Time.MILLI_MUS + " "
+ tick.creationInstant());
}
};
try (final Task<TimeListener> task = t.registerListener(tl)) {
t.unpause();
sleep(1050);
}
final Time lastTime = t.lastTick();
final long now = impl.currentTimeMicros();
final double diffTimeSec = ((double) lastTime.creationTime - now)
/ Time.SECOND_MUS;
System.out
.println("Ticks: " + lastTime.runningElapsedTicks);
System.out.println("diffTimeSec: " + diffTimeSec);
System.out.println("diffTimeSec/tick: "
+ (diffTimeSec / lastTime.runningElapsedTicks));
}
}
}
}
示例3: Wrapper
import com.blockwithme.time.TimeListener; //导入依赖的package包/类
/** Creates a Wrapper. */
public Wrapper(final TimeListener theTask, final Time theTime) {
task = Objects.requireNonNull(theTask, "theTask");
time = Objects.requireNonNull(theTime, "theTime");
}
示例4: ForkingTimeListener
import com.blockwithme.time.TimeListener; //导入依赖的package包/类
/** Creates a Fork, with the given task and Executor. */
public ForkingTimeListener(final TimeListener theTask,
final Executor theExecutor) {
task = Objects.requireNonNull(theTask, "theTask");
executor = Objects.requireNonNull(theExecutor, "theExecutor");
}