Skip to content

Instantly share code, notes, and snippets.

@runarorama
Forked from retronym/scalaz-actor-bug.scala
Created January 10, 2012 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runarorama/1586096 to your computer and use it in GitHub Desktop.
Save runarorama/1586096 to your computer and use it in GitHub Desktop.
scalaz actor bug
object ScalazActorTest extends App {
import scalaz._
import Scalaz._
val running = new AtomicBoolean(false)
object Actor {
var count = 0
def act() {
val b = running.get()
if (b) sys.error("already running!! count = " + count)
running.set(true)
val c = count
count = c + 1
running.set(false)
}
}
val a = actor[Unit](e = (u: Unit) => Actor.act(), err = (t: Throwable) => {println(t); sys.exit(-1)})
var x = 0
while (x < 1000) {
a ! ()
x += 1
}
while(true) {
Thread.sleep(100)
println(Actor.count)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment