本文整理汇总了Java中com.blockwithme.time.Timeline类的典型用法代码示例。如果您正苦于以下问题:Java Timeline类的具体用法?Java Timeline怎么用?Java Timeline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Timeline类属于com.blockwithme.time包,在下文中一共展示了Timeline类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: coreTimeline
import com.blockwithme.time.Timeline; //导入依赖的package包/类
@Override
public Timeline coreTimeline() {
CoreTimeline result = coreTimeline.get();
while (result == null) {
final CoreTimeline ct = new CoreTimeline(this, coreScheduler);
if (coreTimeline.compareAndSet(null, ct)) {
ct.unpause();
LOG.info("Core Timeline created: " + ct);
result = ct;
} else {
// Damn, multiple threads tried at the same time.
try {
ct.close();
} catch (final Exception e) {
LOG.error("Error closing temporary core timeline", e);
}
result = coreTimeline.get();
}
}
return result;
}
示例2: TimelineBuilderImpl2
import com.blockwithme.time.Timeline; //导入依赖的package包/类
/** Creates a TimelineBuilderImpl2. */
public TimelineBuilderImpl2(final Timeline theSource,
final _Timeline theParent, final boolean cloneState,
final _Scheduler theScheduler) {
source = theSource;
parent = theParent;
scheduler = theScheduler;
if (cloneState) {
paused = source.pausedLocally();
startTimePoint = source.startTimePoint();
localTickStep = source.localTickStep();
fixedDurationTicks = source.fixedDurationTicks();
loopWhenReachingEnd = source.loopWhenReachingEnd();
localTickScaling = source.localTickScaling();
timeOffset = source.timeOffset();
} else {
localTickStep = 1;
localTickScaling = 1;
}
}
示例3: testTimelineInterval
import com.blockwithme.time.Timeline; //导入依赖的package包/类
public void testTimelineInterval() throws Exception {
try (final ClockService impl = newClockService()) {
try (final Scheduler sched = impl.newScheduler("sched", null)) {
try (final Timeline t = impl.coreTimeline()
.newChildTimeline(false, sched)
.setFixedDurationTicks(100).paused().create("t")) {
final Interval i = t.toInterval();
System.out.println(i);
final long start = i.start();
final long end = i.end();
assertTrue(i.beforeInterval(start - 1));
assertTrue(i.inInterval(start));
assertTrue(i.inInterval(end));
assertTrue(i.afterInterval(end + 1));
}
}
}
}
示例4: TActorBase
import com.blockwithme.time.Timeline; //导入依赖的package包/类
/**
* Initialize the actor with a Mailbox.
* Null is a valid name.
* Null is a valid parent.
* Null is a valid Timeline, if you are not the future mailbox owner.
*/
protected TActorBase(final TMailbox theMailbox, final String theName,
final TActor theParent, final boolean pin,
final Timeline theTimeline) {
this(theMailbox, theName, theParent, new TActorListenerSupportImpl(
theMailbox), pin, theTimeline);
}
示例5: MyActorNonMBOwner
import com.blockwithme.time.Timeline; //导入依赖的package包/类
public MyActorNonMBOwner(final TMailbox theMailbox, final String name,
final Timeline timeline, final boolean pin) {
super(theMailbox, name, pin, timeline);
hi1 = new TRequestBase<String>(mailbox, timeline) {
@Override
public void processRequest(
final Transport<String> responseProcessor)
throws Exception {
responseProcessor.processResponse("Hello world!");
}
};
}
示例6: IntervalImpl
import com.blockwithme.time.Timeline; //导入依赖的package包/类
/**
* Creates a IntervalImpl.
*/
public IntervalImpl(final Timeline theTimeline, final long theStart,
final long theEnd) {
if (theEnd < theStart) {
throw new IllegalArgumentException("end(" + theEnd + ") < start("
+ theStart + ")");
}
timeline = theTimeline;
start = theStart;
end = theEnd;
}
示例7: create
import com.blockwithme.time.Timeline; //导入依赖的package包/类
@Override
public Timeline create(final String name) {
final long start = (startTimePoint == null) ? source.clockService()
.currentTimeMicros() : startTimePoint;
final DerivedTimeline result = new DerivedTimeline(name, start,
timeOffset, loopWhenReachingEnd, localTickScaling,
fixedDurationTicks, localTickStep, parent, scheduler);
if (paused) {
result.pause();
}
parent.registerListener(result);
return result;
}
示例8: testPauseAndComputedRealTime
import com.blockwithme.time.Timeline; //导入依赖的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));
}
}
}
}
示例9: timeline
import com.blockwithme.time.Timeline; //导入依赖的package包/类
@Override
public final Timeline timeline() {
return timeline;
}
示例10: TRequestBase
import com.blockwithme.time.Timeline; //导入依赖的package包/类
/**
* @param _targetMailbox The target Mailbox
* @param timeline The timeline, coming from the *source* Mailbox
*/
protected TRequestBase(final TMailbox _targetMailbox,
final Timeline timeline) {
super(_targetMailbox);
creationTime = (timeline == null) ? null : timeline.lastTick();
}
示例11: MyActor
import com.blockwithme.time.Timeline; //导入依赖的package包/类
public MyActor(final TMailbox theMailbox, final String name,
final Timeline timeline, final boolean pin) {
super(theMailbox, name, timeline, pin);
}
示例12: timeline
import com.blockwithme.time.Timeline; //导入依赖的package包/类
@Override
public Timeline timeline() {
return null;
}
示例13: relativeTo
import com.blockwithme.time.Timeline; //导入依赖的package包/类
@Override
public Timeline relativeTo() {
return timeline;
}