本文整理汇总了Java中akka.actor.Scheduler类的典型用法代码示例。如果您正苦于以下问题:Java Scheduler类的具体用法?Java Scheduler怎么用?Java Scheduler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Scheduler类属于akka.actor包,在下文中一共展示了Scheduler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createReceive
import akka.actor.Scheduler; //导入依赖的package包/类
@Override
public Receive createReceive() {
return receiveBuilder()
.match(EnterGrid.class, msg -> {
if (userMap.containsKey(msg.user.getUserId())) {
getSender().tell(false, getSelf());
} else {
userMap.put(msg.user.getUserId(), msg.user);
getSender().tell(true, getSelf());
}
}).match(LeaveGrid.class, msg -> {
if (userMap.containsKey(msg.userId)) {
userMap.remove(msg.userId);
}
}).match(GetPlayers.class, msg -> {
Collection<IUser> values = userMap.values();
List<IUser> list = new ArrayList<IUser>();
list.addAll(values);
getSender().tell(list, getSelf());
})
.match(ScheduleTask.class, msg -> {
Scheduler scheduler = getContext().getSystem().scheduler();
if (msg.isOnce()) {
Cancellable cancellable = scheduler.scheduleOnce(Duration.create(msg.getDelay(), TimeUnit.MILLISECONDS), msg.getTask(), getContext().getSystem().dispatcher());
} else {
Cancellable schedule = scheduler.schedule(Duration.create(msg.getDelay(), TimeUnit.MILLISECONDS), Duration.create(msg.getInterval(), TimeUnit.MILLISECONDS), msg.getTask(), getContext().getSystem().dispatcher());
}
})
.build();
}
示例2: schedule
import akka.actor.Scheduler; //导入依赖的package包/类
@Override
public Cancellable schedule(long initialDelay, long interval,
String actorName, Object message) {
ActorRef actor = getActor(actorName);
if (actor == null) {
return null;
}
FiniteDuration initial = new FiniteDuration(initialDelay, TimeUnit.MILLISECONDS);
FiniteDuration gap = new FiniteDuration(interval, TimeUnit.MILLISECONDS);
Scheduler scheduler = actorSystem.scheduler();
return scheduler.schedule(initial, gap, actor, message, actorSystem.dispatcher(), ActorRef.noSender());
}
示例3: runOnce
import akka.actor.Scheduler; //导入依赖的package包/类
@Override
public Cancellable runOnce(long initialDelay, String actorName,
Object message) {
ActorRef actor = getActor(actorName);
if (actor == null) {
return null;
}
FiniteDuration initial = new FiniteDuration(initialDelay, TimeUnit.MILLISECONDS);
Scheduler scheduler = actorSystem.scheduler();
return scheduler.scheduleOnce(initial, actor, message, actorSystem.dispatcher(), ActorRef.noSender());
}
示例4: RaguelThreadsScheduler
import akka.actor.Scheduler; //导入依赖的package包/类
@Inject
public RaguelThreadsScheduler(ActorSystem actorSystem, JPAApi jpaApi, JophielClientAPI jophielClientAPI) {
Scheduler scheduler = actorSystem.scheduler();
ExecutionContextExecutor context = actorSystem.dispatcher();
UserActivityMessagePusher userActivityMessagePusher = new UserActivityMessagePusher(jpaApi, jophielClientAPI, UserActivityMessageServiceImpl.getInstance());
scheduler.schedule(Duration.create(1, TimeUnit.SECONDS), Duration.create(1, TimeUnit.MINUTES), userActivityMessagePusher, context);
}
示例5: UrielThreadsScheduler
import akka.actor.Scheduler; //导入依赖的package包/类
@Inject
public UrielThreadsScheduler(ActorSystem actorSystem, JPAApi jpaApi, ProgrammingSubmissionService programmingSubmissionService, SealtielClientAPI sealtielClientAPI, ContestService contestService, ContestScoreboardService contestScoreboardService, ContestContestantService contestContestantService, JophielClientAPI jophielClientAPI) {
Scheduler scheduler = actorSystem.scheduler();
ExecutionContextExecutor context = actorSystem.dispatcher();
GradingResponsePoller poller = new GradingResponsePoller(scheduler, context, programmingSubmissionService, sealtielClientAPI, TimeUnit.MILLISECONDS.convert(2, TimeUnit.SECONDS));
ScoreboardUpdaterDispatcher updater = new ScoreboardUpdaterDispatcher(jpaApi, scheduler, context, contestService, contestScoreboardService, contestContestantService, programmingSubmissionService);
UserActivityMessagePusher userActivityMessagePusher = new UserActivityMessagePusher(jpaApi, jophielClientAPI, UserActivityMessageServiceImpl.getInstance());
scheduler.schedule(Duration.create(1, TimeUnit.SECONDS), Duration.create(UrielProperties.getInstance().getUrielGradingPollerInterval(), TimeUnit.SECONDS), poller, context);
scheduler.schedule(Duration.create(1, TimeUnit.SECONDS), Duration.create(UrielProperties.getInstance().getUrielScoreboardUpdateInterval(), TimeUnit.SECONDS), updater, context);
scheduler.schedule(Duration.create(1, TimeUnit.SECONDS), Duration.create(UrielProperties.getInstance().getUrielLogPusherInterval(), TimeUnit.SECONDS), userActivityMessagePusher, context);
}
示例6: ScoreboardUpdaterDispatcher
import akka.actor.Scheduler; //导入依赖的package包/类
public ScoreboardUpdaterDispatcher(JPAApi jpaApi, Scheduler scheduler, ExecutionContext executor, ContestService contestService, ContestScoreboardService contestScoreboardService, ContestContestantService contestContestantService, ProgrammingSubmissionService programmingSubmissionService) {
this.jpaApi = jpaApi;
this.scheduler = scheduler;
this.executor = executor;
this.contestService = contestService;
this.contestScoreboardService = contestScoreboardService;
this.contestContestantService = contestContestantService;
this.programmingSubmissionService = programmingSubmissionService;
}
示例7: updateScoreboard
import akka.actor.Scheduler; //导入依赖的package包/类
public static synchronized void updateScoreboard(Scheduler scheduler, ExecutionContext executor, Contest contest, ContestService contestService, ContestScoreboardService contestScoreboardService, ContestContestantService contestContestantService, ProgrammingSubmissionService programmingSubmissionService) {
if (ScoreboardUpdaterDispatcher.updaterExists(contest.getJid())) {
return;
}
ScoreboardUpdater scoreboardUpdater = new ScoreboardUpdater(contest, contestService, contestScoreboardService, contestContestantService, programmingSubmissionService);
scoreboardUpdater.addOnScoreboardUpdateFinishListener(new OnScoreboardUpdateFinishListener() {
@Override
public void onFinish(String contestJid) {
UPDATER_JIDS.remove(contestJid);
}
});
UPDATER_JIDS.add(contest.getJid());
scheduler.scheduleOnce(Duration.create(10, TimeUnit.MILLISECONDS), scoreboardUpdater, executor);
}
示例8: provideScheduler
import akka.actor.Scheduler; //导入依赖的package包/类
@Provides
@Singleton
@Nonnull
public Scheduler provideScheduler(
@Nonnull final ActorSystem actorSystem) {
assert actorSystem != null;
return actorSystem.scheduler();
}
示例9: getScheduler
import akka.actor.Scheduler; //导入依赖的package包/类
protected Scheduler getScheduler() {
return getContext().getSystem().scheduler();
}
示例10: getScheduler
import akka.actor.Scheduler; //导入依赖的package包/类
protected Scheduler getScheduler() {
return systemContext.getScheduler();
}
示例11: getScheduler
import akka.actor.Scheduler; //导入依赖的package包/类
public Scheduler getScheduler() {
return actorSystem.scheduler();
}
示例12: getScheduler
import akka.actor.Scheduler; //导入依赖的package包/类
protected Scheduler getScheduler() {
return systemContext.getScheduler();
}
示例13: getScheduler
import akka.actor.Scheduler; //导入依赖的package包/类
@Override
public final Scheduler getScheduler() {
return akka.scheduler();
}
示例14: scheduler
import akka.actor.Scheduler; //导入依赖的package包/类
/**
* @return an Akka scheduler service
*/
public Scheduler scheduler() {
return system().scheduler();
}
示例15: getScheduler
import akka.actor.Scheduler; //导入依赖的package包/类
/**
* @return an Akka scheduler service
*/
Scheduler getScheduler();