!act #3920 Remove Timeout constructor without unit
This commit is contained in:
parent
1e445b4eba
commit
e1eec61ca5
5 changed files with 10 additions and 19 deletions
|
|
@ -388,7 +388,7 @@ class ActorRefSpec extends AkkaSpec with DefaultTimeout {
|
||||||
}
|
}
|
||||||
|
|
||||||
"stop when sent a poison pill" in {
|
"stop when sent a poison pill" in {
|
||||||
val timeout = Timeout(20000)
|
val timeout = Timeout(20.seconds)
|
||||||
val ref = system.actorOf(Props(new Actor {
|
val ref = system.actorOf(Props(new Actor {
|
||||||
def receive = {
|
def receive = {
|
||||||
case 5 ⇒ sender() ! "five"
|
case 5 ⇒ sender() ! "five"
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import akka.actor.{ ActorSelection, Scheduler }
|
||||||
import scala.concurrent.ExecutionContext
|
import scala.concurrent.ExecutionContext
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
import scala.concurrent.duration.FiniteDuration
|
import scala.concurrent.duration.FiniteDuration
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
object Patterns {
|
object Patterns {
|
||||||
import akka.actor.{ ActorRef, ActorSystem }
|
import akka.actor.{ ActorRef, ActorSystem }
|
||||||
|
|
@ -76,7 +77,7 @@ object Patterns {
|
||||||
* }}}
|
* }}}
|
||||||
*/
|
*/
|
||||||
def ask(actor: ActorRef, message: Any, timeoutMillis: Long): Future[AnyRef] =
|
def ask(actor: ActorRef, message: Any, timeoutMillis: Long): Future[AnyRef] =
|
||||||
scalaAsk(actor, message)(new Timeout(timeoutMillis)).asInstanceOf[Future[AnyRef]]
|
scalaAsk(actor, message)(new Timeout(timeoutMillis, TimeUnit.MILLISECONDS)).asInstanceOf[Future[AnyRef]]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <i>Java API for `akka.pattern.ask`:</i>
|
* <i>Java API for `akka.pattern.ask`:</i>
|
||||||
|
|
@ -140,7 +141,7 @@ object Patterns {
|
||||||
* }}}
|
* }}}
|
||||||
*/
|
*/
|
||||||
def ask(selection: ActorSelection, message: Any, timeoutMillis: Long): Future[AnyRef] =
|
def ask(selection: ActorSelection, message: Any, timeoutMillis: Long): Future[AnyRef] =
|
||||||
scalaAsk(selection, message)(new Timeout(timeoutMillis)).asInstanceOf[Future[AnyRef]]
|
scalaAsk(selection, message)(new Timeout(timeoutMillis, TimeUnit.MILLISECONDS)).asInstanceOf[Future[AnyRef]]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register an onComplete callback on this [[scala.concurrent.Future]] to send
|
* Register an onComplete callback on this [[scala.concurrent.Future]] to send
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,6 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
|
||||||
@SerialVersionUID(1L)
|
@SerialVersionUID(1L)
|
||||||
case class Timeout(duration: FiniteDuration) {
|
case class Timeout(duration: FiniteDuration) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a Timeout from the given number of milliseconds.
|
|
||||||
*/
|
|
||||||
@deprecated("please be explicit about the time unit and use the two-argument version", "2.3")
|
|
||||||
def this(timeout: Long) = this(Duration(timeout, TimeUnit.MILLISECONDS))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a Timeout from the given time unit and factor.
|
* Construct a Timeout from the given time unit and factor.
|
||||||
*/
|
*/
|
||||||
|
|
@ -35,18 +29,10 @@ object Timeout {
|
||||||
*/
|
*/
|
||||||
val zero: Timeout = new Timeout(Duration.Zero)
|
val zero: Timeout = new Timeout(Duration.Zero)
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a Timeout from the given number of milliseconds.
|
|
||||||
*/
|
|
||||||
@deprecated("please be explicit about the time unit and use the two-argument version", "2.3")
|
|
||||||
def apply(timeout: Long): Timeout = new Timeout(timeout)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a Timeout from the given time unit and factor.
|
* Construct a Timeout from the given time unit and factor.
|
||||||
*/
|
*/
|
||||||
def apply(length: Long, unit: TimeUnit): Timeout = new Timeout(length, unit)
|
def apply(length: Long, unit: TimeUnit): Timeout = new Timeout(length, unit)
|
||||||
|
|
||||||
implicit def durationToTimeout(duration: FiniteDuration): Timeout = new Timeout(duration)
|
implicit def durationToTimeout(duration: FiniteDuration): Timeout = new Timeout(duration)
|
||||||
implicit def intToTimeout(timeout: Int): Timeout = new Timeout(timeout)
|
|
||||||
implicit def longToTimeout(timeout: Long): Timeout = new Timeout(timeout)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,3 +38,6 @@ The following, previously deprecated, features have been removed:
|
||||||
|
|
||||||
Note that in router configuration you must now specify if it is a ``pool`` or a ``group``
|
Note that in router configuration you must now specify if it is a ``pool`` or a ``group``
|
||||||
in the way that was introduced in Akka 2.3.
|
in the way that was introduced in Akka 2.3.
|
||||||
|
|
||||||
|
* Timeout constructor without unit
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import scala.concurrent.Await
|
||||||
import scala.concurrent.duration.Duration
|
import scala.concurrent.duration.Duration
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import akka.util.Timeout
|
import akka.util.Timeout
|
||||||
|
import akka.util.Helpers.ConfigOps
|
||||||
import org.zeromq.ZMQException
|
import org.zeromq.ZMQException
|
||||||
import scala.concurrent.duration.FiniteDuration
|
import scala.concurrent.duration.FiniteDuration
|
||||||
import akka.dispatch.{ UnboundedMessageQueueSemantics, RequiresMessageQueue }
|
import akka.dispatch.{ UnboundedMessageQueueSemantics, RequiresMessageQueue }
|
||||||
|
|
@ -45,8 +46,8 @@ object ZeroMQExtension extends ExtensionId[ZeroMQExtension] with ExtensionIdProv
|
||||||
*/
|
*/
|
||||||
class ZeroMQExtension(system: ActorSystem) extends Extension {
|
class ZeroMQExtension(system: ActorSystem) extends Extension {
|
||||||
|
|
||||||
val DefaultPollTimeout: FiniteDuration = Duration(system.settings.config.getMilliseconds("akka.zeromq.poll-timeout"), TimeUnit.MILLISECONDS)
|
val DefaultPollTimeout: FiniteDuration = system.settings.config.getMillisDuration("akka.zeromq.poll-timeout")
|
||||||
val NewSocketTimeout: Timeout = Timeout(Duration(system.settings.config.getMilliseconds("akka.zeromq.new-socket-timeout"), TimeUnit.MILLISECONDS))
|
val NewSocketTimeout: Timeout = Timeout(system.settings.config.getMillisDuration("akka.zeromq.new-socket-timeout"))
|
||||||
|
|
||||||
val pollTimeUnit = if (version.major >= 3) TimeUnit.MILLISECONDS else TimeUnit.MICROSECONDS
|
val pollTimeUnit = if (version.major >= 3) TimeUnit.MILLISECONDS else TimeUnit.MICROSECONDS
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue