Performance: Migrate all @volatile fields on ActorRef
Move them to 1 field:
case class ActorRefSettings(...)
object DefaultActorRefSettings extends ActorRefSettings(defaults...)
@volatile var refSettings: ActorRefSettings = DefaultActorRefSettings
def receiveTimeout(value: Option[Long]) = guard.withGuard { refSettings = refSettings.copyWith(receiveTimeout = value) }
...and so on...
even possible to eliminate all the config methods and have something like this:
class MyActor extends Actor {
def settings = ActorRefSettings(receiveTimeout = Some(50)) //ActorRefSettings could use sensible default values
def receive = { case SomeMessage => doStuff }
}
case class ActorRefSettings(...)
object DefaultActorRefSettings extends ActorRefSettings(defaults...)
@volatile var refSettings: ActorRefSettings = DefaultActorRefSettings
def receiveTimeout(value: Option[Long]) = guard.withGuard { refSettings = refSettings.copyWith(receiveTimeout = value) }
...and so on...
even possible to eliminate all the config methods and have something like this:
class MyActor extends Actor {
def settings = ActorRefSettings(receiveTimeout = Some(50)) //ActorRefSettings could use sensible default values
def receive = { case SomeMessage => doStuff }
}
Leave a comment
6 volatile fields removed so far
on 2010-10-08 13:34 *
By viktorklang
Another one bites the dust
on 2010-10-08 14:00 *
By viktorklang
And another one gone
on 2010-10-28 11:16 *
By Jonas Bonér
Status on this one?
on 2010-10-28 11:51 *
By viktorklang
What's done:
1) Replace fields that can be inferred instead
2) Fold fields that can be merged
What's left:
1) Make an abstraction so that ActorRef only needs 1 mutable field, that can be backed by an AtomicReference
1) Replace fields that can be inferred instead
2) Fold fields that can be merged
What's left:
1) Make an abstraction so that ActorRef only needs 1 mutable field, that can be backed by an AtomicReference