Skip to content

Commit

Permalink
!act #3920 Remove Timeout constructor without unit
Browse files Browse the repository at this point in the history
  • Loading branch information
patriknw committed Mar 14, 2014
1 parent 1e445b4 commit e1eec61
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class ActorRefSpec extends AkkaSpec with DefaultTimeout {
}

"stop when sent a poison pill" in {
val timeout = Timeout(20000)
val timeout = Timeout(20.seconds)
val ref = system.actorOf(Props(new Actor {
def receive = {
case 5 sender() ! "five"
Expand Down
5 changes: 3 additions & 2 deletions akka-actor/src/main/scala/akka/pattern/Patterns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import akka.actor.{ ActorSelection, Scheduler }
import scala.concurrent.ExecutionContext
import java.util.concurrent.Callable
import scala.concurrent.duration.FiniteDuration
import java.util.concurrent.TimeUnit

object Patterns {
import akka.actor.{ ActorRef, ActorSystem }
Expand Down Expand Up @@ -76,7 +77,7 @@ object Patterns {
* }}}
*/
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>
Expand Down Expand Up @@ -140,7 +141,7 @@ object Patterns {
* }}}
*/
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
Expand Down
14 changes: 0 additions & 14 deletions akka-actor/src/main/scala/akka/util/Timeout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
@SerialVersionUID(1L)
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.
*/
Expand All @@ -35,18 +29,10 @@ object Timeout {
*/
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.
*/
def apply(length: Long, unit: TimeUnit): Timeout = new Timeout(length, unit)

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)
}
3 changes: 3 additions & 0 deletions akka-docs/rst/project/migration-guide-2.3.x-2.4.x.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
in the way that was introduced in Akka 2.3.

* Timeout constructor without unit

5 changes: 3 additions & 2 deletions akka-zeromq/src/main/scala/akka/zeromq/ZeroMQExtension.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import scala.concurrent.Await
import scala.concurrent.duration.Duration
import java.util.concurrent.TimeUnit
import akka.util.Timeout
import akka.util.Helpers.ConfigOps
import org.zeromq.ZMQException
import scala.concurrent.duration.FiniteDuration
import akka.dispatch.{ UnboundedMessageQueueSemantics, RequiresMessageQueue }
Expand Down Expand Up @@ -45,8 +46,8 @@ object ZeroMQExtension extends ExtensionId[ZeroMQExtension] with ExtensionIdProv
*/
class ZeroMQExtension(system: ActorSystem) extends Extension {

val DefaultPollTimeout: FiniteDuration = Duration(system.settings.config.getMilliseconds("akka.zeromq.poll-timeout"), TimeUnit.MILLISECONDS)
val NewSocketTimeout: Timeout = Timeout(Duration(system.settings.config.getMilliseconds("akka.zeromq.new-socket-timeout"), TimeUnit.MILLISECONDS))
val DefaultPollTimeout: FiniteDuration = system.settings.config.getMillisDuration("akka.zeromq.poll-timeout")
val NewSocketTimeout: Timeout = Timeout(system.settings.config.getMillisDuration("akka.zeromq.new-socket-timeout"))

val pollTimeUnit = if (version.major >= 3) TimeUnit.MILLISECONDS else TimeUnit.MICROSECONDS

Expand Down

0 comments on commit e1eec61

Please sign in to comment.