Skip to content

Instantly share code, notes, and snippets.

@retronym
Created January 9, 2012 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save retronym/1583475 to your computer and use it in GitHub Desktop.
Save retronym/1583475 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