Skip to content

Instantly share code, notes, and snippets.

@mgodave
Created December 4, 2016 19:50
Show Gist options
  • Save mgodave/9e096b56d141540002dc09c0e600e2d4 to your computer and use it in GitHub Desktop.
Save mgodave/9e096b56d141540002dc09c0e600e2d4 to your computer and use it in GitHub Desktop.
import com.twitter.concurrent.AsyncStream
import com.twitter.concurrent.AsyncStream._
import com.twitter.util.{Await, Future}
object MapConcurrentLeak extends App{
def stream(i: Int, stop: Int): AsyncStream[Int] = {
if (i >= stop) fromFuture(Future.never)
else i +:: stream(i + 1, stop)
}
Await.ready(
stream(0, 1000000)
.mapConcurrent(10)(_ => Future.Done)
.force
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment