-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f42c57d
commit b6d4480
Showing
24 changed files
with
49 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
project/* | ||
target/* | ||
**/project/* | ||
**/target/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,21 @@ | ||
import akka.actor.Actor | ||
import akka.actor.ActorSystem | ||
import akka.actor.Props | ||
import scala.concurrent.Await | ||
import scala.concurrent.Future | ||
import akka.pattern.ask | ||
import akka.util.Timeout | ||
import scala.concurrent.duration._ | ||
|
||
// using Ask & Future | ||
|
||
case object StopMsg; | ||
case class Msg(text : String) | ||
|
||
class HelloActor extends Actor { | ||
def receive = { | ||
case Msg(t) => { | ||
if (t == "hello") sender ! s" $t back to you" | ||
else sender ! s" does '$t' mean hello ?" | ||
} | ||
case StopMsg => context.stop(self) | ||
case _ => sender ! " huh?" | ||
case "hello" => println("hello back at you") | ||
case _ => println("huh?") | ||
} | ||
} | ||
|
||
object Main extends App { | ||
val system = ActorSystem("HelloSystem") | ||
// default Actor constructor | ||
val helloActor = system.actorOf(Props[HelloActor], name = "helloactor") | ||
helloActor ! "hello" | ||
helloActor ! "bonjour" | ||
|
||
implicit val timeout = Timeout(5 seconds) | ||
|
||
val future = helloActor ? Msg("hello") | ||
//val result = Await.result(future, timeout.duration).asInstanceOf[String] | ||
val result = Await.result(future, 1 second).asInstanceOf[String] | ||
println(result) | ||
|
||
//another way | ||
val future2: Future[String] = ask(helloActor, Msg("bonjour")).mapTo[String] | ||
val result2 = Await.result(future2, 1 second) | ||
println(result2) | ||
|
||
helloActor ! StopMsg | ||
Thread.sleep(5L) | ||
Thread.sleep(1000L) | ||
system.shutdown() | ||
} |
2 changes: 1 addition & 1 deletion
2
step1/target/resolution-cache/hello-test-1/hello-test-1_2.11/1.0/resolved.xml.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#hello-test-1#hello-test-1_2.11;1.0 resolved revisions | ||
#Sun Mar 27 22:55:15 CEST 2016 | ||
#Mon Mar 28 19:42:35 CEST 2016 | ||
+organisation\:\#@\#\:+org.scala-lang\:\#@\#\:+branch\:\#@\#\:+@\#\:NULL\:\#@\:\#@\#\:+module\:\#@\#\:+scala-library\:\#@\#\:+revision\:\#@\#\:+2.11.7\:\#@\#\:=2.11.7 ? 2.11.7 null | ||
+organisation\:\#@\#\:+com.typesafe.akka\:\#@\#\:+branch\:\#@\#\:+@\#\:NULL\:\#@\:\#@\#\:+module\:\#@\#\:+akka-actor_2.11\:\#@\#\:+revision\:\#@\#\:+2.3.9\:\#@\#\:=2.3.9 release 2.3.9 null | ||
+organisation\:\#@\#\:+org.scala-lang\:\#@\#\:+branch\:\#@\#\:+@\#\:NULL\:\#@\:\#@\#\:+module\:\#@\#\:+scala-compiler\:\#@\#\:+revision\:\#@\#\:+2.11.7\:\#@\#\:=2.11.7 release 2.11.7 null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-4 Bytes
(100%)
step1/target/scala-2.11/classes/HelloActor$$anonfun$receive$1.class
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
step1/target/streams/$global/update/$global/streams/update_cache_2.11/output
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.