Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def start(relativePath: String)(handler: Request => Response): Subscription = {
- ...
- println("pong 1")
- // 2. create a cancellation token to run an asynchronous computation (hint: use the Future.run companion method)
- // ct is a CancellationToken
- val working = Future.run() { ct =>
- Future {
- while (ct.nonCancelled) {
- println("pong 2")
- // 3. in this asynchronous computation, while the token is not
- // cancelled, await the next request from the listener and then
- // respond to it
- ... do some thing
- }
- println("done")
- }
- }
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment