This file contains hidden or 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
package akka.training | |
import akka.actor.Supervisor | |
import akka.config.Supervision._ | |
import akka.actor.Actor | |
import akka.actor.Actor._ | |
import akka.routing._ | |
import akka.config.Supervision.OneForOneStrategy | |
import akka.actor.RemoteActorRef | |
import akka.actor.ActorRef |
This file contains hidden or 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
set name := "akka training" | |
set scalaVersion := "2.9.1" | |
set resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" | |
set libraryDependencies ++= Seq("se.scalablesolutions.akka" % "akka-actor" % "1.2", "se.scalablesolutions.akka" % "akka-actor" % "1.2", "se.scalablesolutions.akka" % "akka-remote" % "1.2", "se.scalablesolutions.akka" % "akka-testkit" % "1.2", "se.scalablesolutions.akka" % "akka-stm" % "1.2", "org.scalatest" %% "scalatest" % "1.6.1" % "test", "junit" % "junit" % "4.5" % "test") | |
session save |
This file contains hidden or 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
import akka.actor._ //Actor | |
import akka.actor.Actor._ //actorOf | |
import akka.dispatch._ //Futures | |
import java.util.concurrent.CountDownLatch //Need for demo | |
//Create an Actor here... | |
class AnActor(var state : String) extends Actor { |
This file contains hidden or 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
set libraryDependencies ++= Seq("se.scalablesolutions.akka" % "akka-actor" % "1.3-RC6", "se.scalablesolutions.akka" % "akka-actor" % "1.3-RC6", "se.scalablesolutions.akka" % "akka-remote" % "1.3-RC6", "se.scalablesolutions.akka" % "akka-testkit" % "1.3-RC6", "se.scalablesolutions.akka" % "akka-stm" % "1.3-RC6", "org.scalatest" %% "scalatest" % "1.6.1" % "test", "junit" % "junit" % "4.5" % "test") | |
session save |
This file contains hidden or 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
//your first actor | |
class MyActor extends akka.actor.Actor { | |
def receive = { //when a message is received... | |
case m =>println(m.toString) //...print it out | |
} | |
} | |
val actorRef = akka.actor.Actor.actorOf[MyActor].start() //start the actor | |
actorRef ! "Congratulations from your first Akka actor" //send a message | |
actorRef ! akka.actor.PoisonPill //the actor will stop when this message is received |
This file contains hidden or 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
_asyncWrapper1 = [[AsyncURLWrapper alloc] initWithRequest:request2 delegate:self retries:5]; | |
_asyncWrapper2 = [[AsyncURLWrapper alloc] initWithRequest:request1 delegate:self retries: 5]; |
This file contains hidden or 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
- (void) didFinish: (NSData*) data sender: (AsyncURLWrapper*) blob | |
{ | |
if (blob == _asyncWrapper1) { | |
NSLog(@"data 1: %@", data); | |
} | |
if (blob == _asyncWrapper2) { | |
NSLog(@"data 2: %@", data); | |
} | |
} |
This file contains hidden or 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
#pragma mark - AsyncURLWrapper delegates | |
- (void) didFinish: (NSData*) data sender: (AsyncURLWrapper*) blob | |
{ | |
if (blob == _asyncWrapper1) { | |
NSLog(@"string from wrapper 1: %@", [AsyncURLWrapper asUTF8String:data]); | |
} | |
if (blob == _asyncWrapper2) { | |
NSLog(@"string from wrapper 2: %@", [AsyncURLWrapper asUTF8String:data]); | |
} | |
} |
This file contains hidden or 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
#import <Foundation/Foundation.h> | |
@class AsyncURLWrapper; | |
@protocol AsyncURLWrapperDelegate <NSObject> | |
@optional | |
- (void) didFinish: (NSData*) data sender: (AsyncURLWrapper*) urlWrapper response: (NSHTTPURLResponse*) response; | |
- (void) didFail: (NSError*) error sender: (AsyncURLWrapper*) urlWrapper; | |
- (void) beforeRetry: (NSError*) error sender: (AsyncURLWrapper*) urlWrapper; | |
- (void) didUpdateProgress: (float) percentCompleted sender: (AsyncURLWrapper*) urlWrapper; |
This file contains hidden or 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
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView | |
{ | |
if (scrollView.contentOffset.y == | |
self.table.contentSize.height - self.table.frame.size.height) | |
|| (self.table.contentSize.height - self.table.frame.size.height ) < 0) { | |
//When table is dragged this will be enabled | |
[self loadMoreElements]; | |
} | |
} |
OlderNewer