简体   繁体   中英

Play 2.5 akka.actor.ActorSystem isTerminated method deprecated

I'm upgrading my project to Play 2.5. In the previous version I used the following code to schedule task via Akka:

private ActorSystem actorSystem = Play.current().injector().instanceOf(ActorSystem.class);

    private void scheduleUpdate() {
        if (actorSystem.isTerminated()) {
            return;
        }
        //run schedule code
    }

But isTerminated method (returning boolean) is deprecated now and I'm encouraged to use whenTerminated instead. However, I'm not sure how to properly refactor this code here, since whenTerminated seems to have completely different functionality. If someone gives me an advice about this - it would be quite helpful.

ActorSystem.whenTerminated返回一个Future<Terminated> ,它是Scala数据结构,与Java 8中添加的CompletableFuture非常相似。您可以通过方法.isCompleted()来查询它是否已完成,以模仿您的旧逻辑。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM