clarify context needed for ActorDSL.actor() and add @implicitNotFound
This commit is contained in:
parent
6321663471
commit
36cbf96d8e
3 changed files with 14 additions and 4 deletions
|
|
@ -7,14 +7,21 @@ package akka.actor
|
||||||
import language.postfixOps
|
import language.postfixOps
|
||||||
|
|
||||||
import akka.testkit.{ AkkaSpec, EventFilter }
|
import akka.testkit.{ AkkaSpec, EventFilter }
|
||||||
//#import
|
|
||||||
import akka.actor.ActorDSL._
|
import akka.actor.ActorDSL._
|
||||||
//#import
|
|
||||||
import akka.event.Logging.Warning
|
import akka.event.Logging.Warning
|
||||||
import scala.concurrent.{ Await, Future }
|
import scala.concurrent.{ Await, Future }
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import java.util.concurrent.TimeoutException
|
import java.util.concurrent.TimeoutException
|
||||||
|
|
||||||
|
class ActorDSLDummy {
|
||||||
|
//#import
|
||||||
|
import akka.actor.ActorDSL._
|
||||||
|
import akka.actor.ActorSystem
|
||||||
|
|
||||||
|
implicit val system = ActorSystem("demo")
|
||||||
|
//#import
|
||||||
|
}
|
||||||
|
|
||||||
class ActorDSLSpec extends AkkaSpec {
|
class ActorDSLSpec extends AkkaSpec {
|
||||||
|
|
||||||
val echo = system.actorOf(Props(new Actor {
|
val echo = system.actorOf(Props(new Actor {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import akka.util.Collections.EmptyImmutableSeq
|
||||||
import scala.util.{ Success, Failure }
|
import scala.util.{ Success, Failure }
|
||||||
import java.util.concurrent.atomic.AtomicLong
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
import scala.concurrent.{ ExecutionContext, Future, Promise }
|
import scala.concurrent.{ ExecutionContext, Future, Promise }
|
||||||
|
import scala.annotation.implicitNotFound
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for all ActorRef providers to implement.
|
* Interface for all ActorRef providers to implement.
|
||||||
|
|
@ -156,6 +157,7 @@ trait ActorRefProvider {
|
||||||
* Interface implemented by ActorSystem and ActorContext, the only two places
|
* Interface implemented by ActorSystem and ActorContext, the only two places
|
||||||
* from which you can get fresh actors.
|
* from which you can get fresh actors.
|
||||||
*/
|
*/
|
||||||
|
@implicitNotFound("implicit ActorRefFactory required: if outside of an Actor you need an implicit ActorSystem, inside of an actor this should be the implicit ActorContext")
|
||||||
trait ActorRefFactory {
|
trait ActorRefFactory {
|
||||||
/**
|
/**
|
||||||
* INTERNAL API
|
* INTERNAL API
|
||||||
|
|
|
||||||
|
|
@ -162,8 +162,9 @@ infrastructure is bundled in the following import:
|
||||||
|
|
||||||
.. includecode:: ../../../akka-actor-tests/src/test/scala/akka/actor/ActorDSLSpec.scala#import
|
.. includecode:: ../../../akka-actor-tests/src/test/scala/akka/actor/ActorDSLSpec.scala#import
|
||||||
|
|
||||||
This import is assumed for all code samples throughout this section. To define
|
This import is assumed for all code samples throughout this section. The
|
||||||
a simple actor, the following is sufficient:
|
implicit actor system serves as :class:`ActorRefFactory` for all examples
|
||||||
|
below. To define a simple actor, the following is sufficient:
|
||||||
|
|
||||||
.. includecode:: ../../../akka-actor-tests/src/test/scala/akka/actor/ActorDSLSpec.scala#simple-actor
|
.. includecode:: ../../../akka-actor-tests/src/test/scala/akka/actor/ActorDSLSpec.scala#simple-actor
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue