Java 类akka.actor.Scheduler 实例源码

项目:CodeBroker    文件:GridActor.java   
@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();
}
项目:polyguice    文件:PolkaImpl.java   
@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());
}
项目:polyguice    文件:PolkaImpl.java   
@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());
}
项目:raguel    文件:RaguelThreadsScheduler.java   
@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);
}
项目:uriel    文件:UrielThreadsScheduler.java   
@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);
}
项目:uriel    文件:ScoreboardUpdaterDispatcher.java   
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;
}
项目:uriel    文件:ScoreboardUpdaterDispatcher.java   
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);
}
项目:speedtools    文件:ServicesModule.java   
@Provides
@Singleton
@Nonnull
public Scheduler provideScheduler(
        @Nonnull final ActorSystem actorSystem) {
    assert actorSystem != null;
    return actorSystem.scheduler();
}
项目:commelina    文件:AbstractServiceActor.java   
protected Scheduler getScheduler() {
    return getContext().getSystem().scheduler();
}
项目:iotplatform    文件:AbstractContextAwareMsgProcessor.java   
protected Scheduler getScheduler() {
  return systemContext.getScheduler();
}
项目:iotplatform    文件:ActorSystemContext.java   
public Scheduler getScheduler() {
    return actorSystem.scheduler();
}
项目:thingsboard    文件:AbstractContextAwareMsgProcessor.java   
protected Scheduler getScheduler() {
    return systemContext.getScheduler();
}
项目:thingsboard    文件:ActorSystemContext.java   
public Scheduler getScheduler() {
    return actorSystem.scheduler();
}
项目:wicket-akka    文件:AkkaWebApplication.java   
@Override
public final Scheduler getScheduler() {
    return akka.scheduler();
}
项目:wicket-akka    文件:Akka.java   
/**
 * @return an Akka scheduler service
 */
public Scheduler scheduler() {
    return system().scheduler();
}
项目:wicket-akka    文件:IAkkaApplication.java   
/**
 * @return an Akka scheduler service
 */
Scheduler getScheduler();