I really like the new Future
API in Scala 2.10, and I'm trying to use it for a simple script. The gist of the program is as follows:
- HTTP request to some URL
- User input required based on the response
- Further processing
The idea is to implement everything as a chain of Futures (flatmap, etc.), but here's my problem:
I'm currently doing my testing in SBT, so when the main thread finishes, SBT goes back into its REPL. Meanwhile, my Future
computation is still waiting on my user input. Once I start trying to type, it seems that the readLine
call in step 2 is fighting with whatever input SBT is trying to do.
For example, if my intended input was abcdefghijklmnop
, my program would receive a random subset of that, like adghip
, and then when it finishes, SBT will tell me that bcefjklmno
isn't a command.
How can I either...
- Delay the main thread from finishing before the Futures' daemon threads
- or Replace
readLine
with some other call that won't fight with SBT