Created
November 10, 2018 13:46
-
-
Save inmyth/f52c2169751981598c58ed9c53635dac to your computer and use it in GitHub Desktop.
Vertx event loop blocking & non-blocking test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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