本文整理汇总了Scala中scala.concurrent.duration.DurationInt类的典型用法代码示例。如果您正苦于以下问题:Scala DurationInt类的具体用法?Scala DurationInt怎么用?Scala DurationInt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DurationInt类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: UserTokenDaoSpec
//设置package包名称以及导入依赖的类
package daos
import scala.concurrent.Await
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.test._
import play.api.test.Helpers._
import org.joda.time.DateTime
import org.specs2.mutable.Specification
import java.util.UUID
import scala.concurrent.Await
import scala.concurrent.duration.DurationInt
import models.UserToken
class UserTokenDaoSpec extends Specification {
val timeout = DurationInt(10).seconds
def fakeApp = FakeApplication(additionalConfiguration = Map("mongodb.uri" -> "mongodb://localhost:27017/test"))
def withUserTokenDao[T](t:UserTokenDao => T):T = running(fakeApp) {
val userTokenDao = new MongoUserTokenDao
Await.ready(userTokenDao.tokens.drop(), timeout)
t(userTokenDao)
}
val token = UserToken(id=UUID.randomUUID(), userId=UUID.randomUUID(), "[email protected]", new DateTime(), true)
"UserTokenDao" should {
"Persist and find a token" in withUserTokenDao { userTokenDao =>
val future = for {
_ <- userTokenDao.save(token)
maybeToken <- userTokenDao.find(token.id)
} yield maybeToken.map(_ == token)
Await.result(future, timeout) must beSome(true)
}
"Remove a token" in withUserTokenDao { userTokenDao =>
val future = for {
_ <- userTokenDao.save(token)
_ <- userTokenDao.remove(token.id)
maybeToken <- userTokenDao.find(token.id)
} yield maybeToken
Await.result(future, timeout) must beNone
}
}
}
开发者ID:Viva-con-Agua,项目名称:drops,代码行数:51,代码来源:UserTokenDaoSpec.scala
示例2: ParentActor
//设置package包名称以及导入依赖的类
package com.github.uryyyyyyy.akka.helloworld.faultTolerance
import java.io.IOException
import akka.actor.SupervisorStrategy.{Escalate, Resume}
import akka.actor.{Actor, OneForOneStrategy, Props}
import scala.concurrent.duration.DurationInt
class ParentActor extends Actor {
override val supervisorStrategy =OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = new DurationInt(1).second ) {
case _: IOException => Resume
case _: Exception => Escalate
}
def receive = {
case x => {
val actor1 = context.actorOf(Props[ChildActor1])
val actor2 = context.actorOf(Props[ChildActor2])
// val actor3 = context.actorSelection("akka.tcp://notExist")
val f1 = actor1 ! "hello"
val f2 = actor2 ! "hello"
val f3 = actor2 ! "hello"
// val f3 = actor3 ! "hello"
}
}
}
开发者ID:uryyyyyyy,项目名称:akkaSample,代码行数:29,代码来源:ParentActor.scala
注:本文中的scala.concurrent.duration.DurationInt类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论