As far as I'm aware, there is no good way to kill a computation within the map
function of a parallel computation without you, yourself, building in a means of throwing an InteruptException
. Even then, I do not know what, if anything, that might accomplish. However, if you had to do so...
class MyInteruptableFunction[+A,-B](f: A => B, waitCap: Long) extends (A => B){
def apply(that: A) ={
val timer = new Timer
timer schedule (new MyTaskThatThowsAnException, waitCap)
val out = f(that)
timer cancel ()
out
}
}
Then do this:
val c = collection.par.map{ new MyInterruptableFunction(f, 42) } //42 is the answer!
It's ugly, verbose, and error prone (your task can complete and still the error can be thrown!) So if it's an "I have no choice but to do this" then do it but please, fix the problem on their end. Raise hell with their manager. Do everything you can to make their lives difficult. I'm sure you have but...