Making sure that the ContinuousCancellable can never be re-initialized
This commit is contained in:
parent
c0cead3aad
commit
07c9bfe6d7
1 changed files with 12 additions and 3 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
package akka.actor
|
package akka.actor
|
||||||
|
|
||||||
import akka.util.Duration
|
import akka.util.Duration
|
||||||
import org.jboss.netty.akka.util.{ TimerTask, HashedWheelTimer, Timeout ⇒ HWTimeout }
|
import org.jboss.netty.akka.util.{ TimerTask, HashedWheelTimer, Timeout ⇒ HWTimeout, Timer }
|
||||||
import akka.event.LoggingAdapter
|
import akka.event.LoggingAdapter
|
||||||
import akka.dispatch.MessageDispatcher
|
import akka.dispatch.MessageDispatcher
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
|
|
@ -207,14 +207,23 @@ class DefaultScheduler(hashedWheelTimer: HashedWheelTimer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private[akka] object ContinuousCancellable {
|
||||||
|
val initial: HWTimeout = new HWTimeout {
|
||||||
|
override def getTimer: Timer = null
|
||||||
|
override def getTask: TimerTask = null
|
||||||
|
override def isExpired: Boolean = false
|
||||||
|
override def isCancelled: Boolean = false
|
||||||
|
override def cancel: Unit = ()
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Wrapper of a [[org.jboss.netty.akka.util.Timeout]] that delegates all
|
* Wrapper of a [[org.jboss.netty.akka.util.Timeout]] that delegates all
|
||||||
* methods. Needed to be able to cancel continuous tasks,
|
* methods. Needed to be able to cancel continuous tasks,
|
||||||
* since they create new Timeout for each tick.
|
* since they create new Timeout for each tick.
|
||||||
*/
|
*/
|
||||||
private[akka] class ContinuousCancellable extends AtomicReference[HWTimeout] with Cancellable {
|
private[akka] class ContinuousCancellable extends AtomicReference[HWTimeout](ContinuousCancellable.initial) with Cancellable {
|
||||||
private[akka] def init(initialTimeout: HWTimeout): this.type = {
|
private[akka] def init(initialTimeout: HWTimeout): this.type = {
|
||||||
assert(compareAndSet(null, initialTimeout))
|
compareAndSet(ContinuousCancellable.initial, initialTimeout)
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue