Skip to content

Commit

Permalink
add clearing of message from tail node to avoid memory leaks when que…
Browse files Browse the repository at this point in the history
…ue is empty and no new messages come
  • Loading branch information
Andriy Plokhotnyuk committed Jun 18, 2013
1 parent cdd4109 commit 718ef70
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion concurrent/src/main/scala/scalaz/concurrent/Actor.scala
Expand Up @@ -56,6 +56,7 @@ final case class Actor[A](handler: A => Unit, onError: Throwable => Unit = throw
val t = tail.get
val n = batchHandle(t, 1024)
if (n ne t) {
n.a = null.asInstanceOf[A]
tail.lazySet(n)
schedule()
} else {
Expand All @@ -78,7 +79,7 @@ final case class Actor[A](handler: A => Unit, onError: Throwable => Unit = throw
}
}

private class Node[A](val a: A = null.asInstanceOf[A]) extends AtomicReference[Node[A]]
private class Node[A](var a: A = null.asInstanceOf[A]) extends AtomicReference[Node[A]]

object Actor extends ActorFunctions with ActorInstances

Expand Down

0 comments on commit 718ef70

Please sign in to comment.