当前位置: 首页>>代码示例>>Java>>正文


Java Scheduler类代码示例

本文整理汇总了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();
}
 
开发者ID:zerosoft,项目名称:CodeBroker,代码行数:31,代码来源:GridActor.java

示例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());
}
 
开发者ID:flipkart-incubator,项目名称:polyguice,代码行数:14,代码来源:PolkaImpl.java

示例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());
}
 
开发者ID:flipkart-incubator,项目名称:polyguice,代码行数:13,代码来源:PolkaImpl.java

示例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);
}
 
开发者ID:judgels,项目名称:raguel,代码行数:10,代码来源:RaguelThreadsScheduler.java

示例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);
}
 
开发者ID:judgels,项目名称:uriel,代码行数:14,代码来源:UrielThreadsScheduler.java

示例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;
}
 
开发者ID:judgels,项目名称:uriel,代码行数:10,代码来源:ScoreboardUpdaterDispatcher.java

示例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);
}
 
开发者ID:judgels,项目名称:uriel,代码行数:16,代码来源:ScoreboardUpdaterDispatcher.java

示例8: provideScheduler

import akka.actor.Scheduler; //导入依赖的package包/类
@Provides
@Singleton
@Nonnull
public Scheduler provideScheduler(
        @Nonnull final ActorSystem actorSystem) {
    assert actorSystem != null;
    return actorSystem.scheduler();
}
 
开发者ID:tomtom-international,项目名称:speedtools,代码行数:9,代码来源:ServicesModule.java

示例9: getScheduler

import akka.actor.Scheduler; //导入依赖的package包/类
protected Scheduler getScheduler() {
    return getContext().getSystem().scheduler();
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:4,代码来源:AbstractServiceActor.java

示例10: getScheduler

import akka.actor.Scheduler; //导入依赖的package包/类
protected Scheduler getScheduler() {
  return systemContext.getScheduler();
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:4,代码来源:AbstractContextAwareMsgProcessor.java

示例11: getScheduler

import akka.actor.Scheduler; //导入依赖的package包/类
public Scheduler getScheduler() {
    return actorSystem.scheduler();
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:4,代码来源:ActorSystemContext.java

示例12: getScheduler

import akka.actor.Scheduler; //导入依赖的package包/类
protected Scheduler getScheduler() {
    return systemContext.getScheduler();
}
 
开发者ID:thingsboard,项目名称:thingsboard,代码行数:4,代码来源:AbstractContextAwareMsgProcessor.java

示例13: getScheduler

import akka.actor.Scheduler; //导入依赖的package包/类
@Override
public final Scheduler getScheduler() {
    return akka.scheduler();
}
 
开发者ID:l0rdn1kk0n,项目名称:wicket-akka,代码行数:5,代码来源:AkkaWebApplication.java

示例14: scheduler

import akka.actor.Scheduler; //导入依赖的package包/类
/**
 * @return an Akka scheduler service
 */
public Scheduler scheduler() {
    return system().scheduler();
}
 
开发者ID:l0rdn1kk0n,项目名称:wicket-akka,代码行数:7,代码来源:Akka.java

示例15: getScheduler

import akka.actor.Scheduler; //导入依赖的package包/类
/**
 * @return an Akka scheduler service
 */
Scheduler getScheduler();
 
开发者ID:l0rdn1kk0n,项目名称:wicket-akka,代码行数:5,代码来源:IAkkaApplication.java


注:本文中的akka.actor.Scheduler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。