pellekrogholt

Untitled

Dec 4th, 2013
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. def start(relativePath: String)(handler: Request => Response): Subscription = {
  2.  
  3. ...
  4.  
  5. println("pong 1")
  6. // 2. create a cancellation token to run an asynchronous computation (hint: use the Future.run companion method)
  7. // ct is a CancellationToken
  8. val working = Future.run() { ct =>
  9. Future {
  10. while (ct.nonCancelled) {
  11. println("pong 2")
  12. // 3. in this asynchronous computation, while the token is not
  13. // cancelled, await the next request from the listener and then
  14. // respond to it
  15. ... do some thing
  16. }
  17. println("done")
  18. }
  19. }
  20.  
  21. ...
  22. }
Advertisement
Add Comment
Please, Sign In to add comment