Skip to content

Instantly share code, notes, and snippets.

@inmyth
Created November 10, 2018 13:46
Show Gist options
  • Select an option

  • Save inmyth/f52c2169751981598c58ed9c53635dac to your computer and use it in GitHub Desktop.

Select an option

Save inmyth/f52c2169751981598c58ed9c53635dac to your computer and use it in GitHub Desktop.
Vertx event loop blocking & non-blocking test
val vertx = Vertx.vertx()
vertx.createHttpServer.requestHandler(p => {
p.path match {
case a if a contains "/tes1" =>
val f = for {
f1 <- Future (Thread.sleep(5000))
f2 <- Future (Thread.sleep(5000))
} yield f2
f.onComplete{
case Success(z) => p.response().end("done sleep")
}
case a if a contains "/tes2" => p.response().end("immediate")
case a if a contains "/tes3" =>
Thread.sleep(5000)
p.response().end("blocked")
case _ =>
}
}).listen(8066)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment