Computation with time limit

后端 未结 9 2354
你的背包
你的背包 2021-01-02 12:08

I\'m trying to write a construct which allows me to run computations in a given time window. Something like:

def expensiveComputation(): Double = //... some          


        
9条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-02 12:54

    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.

提交回复
热议问题