I\'m trying to write a construct which allows me to run computations in a given time window. Something like:
def expensiveComputation(): Double = //... some
If you're very seriously in need of this you could create a compiler plugin that inserts check blocks in loops and conditions. These check blocks can then check Thread.isInterrupted() and throw an Exception to escape.
You could possibly use an annotation, i.e. @interruptible, to mark the methods to enhance.