Having the need to test some methods that may cause a timeout, I want to create an auxiliary function for this. He must return a Future that never completes:
def neverCompletes[T]: Future[T] = { ... }
But I wonder how can I do this? I could do this:
def neverCompletes[T]: Future[T] = { val p = Promise[T]() future { while(true) { } } onComplete { case x => p complete x // needed? println("something went wrong!!!") // something is wrong... } p.future }
But there must be a better way to achieve this. I'm also not sure if p complete x // needed? .
scala concurrency future
ア レ ッ ク ス
source share