I'm trying to get a very simple recurring function loop running, according to these samples:
http://doc.akka.io/docs/akka/2.1.2/scala/scheduler.html
The code:
import akka.actor.Actor
import akka.actor.Props
import scala.concurrent.duration._
object Main extends Application {
val system = akka.actor.ActorSystem("system") // this was missing!
import system.dispatcher
system.scheduler.schedule( 0 milliseconds, (10*1000) milliseconds, {
println( "click!" )
})
}
I get (sbt):
> .../src/Main.scala:34: not found: value system [error] import
> system.dispatcher [error] ^ [error]
> .../src/Main.scala:36: not found: value system [error]
> system.scheduler.schedule( 0 milliseconds /*initial delay*/,
> (entry.secs*1000) milliseconds /*delay between*/, { [error] ^
Where is the system
supposed to be coming from?
Addendum:
I'm having the code within a 'main()' function, and I haven't inherited anything from Actor
or ActorSystem
. The point is I'd like to schedule functions but no go into actors with this. Is the framework thinking I must derive from something (if so, it kind-of should say it?).