I am thinking about a situation in which if have different ways to compute the same thing. I want both calculations to start and when one of them finishes, give me the result. I then can abandon the other calculation.
In other words, I have two functions
g that mathematically give the same answer, but are implemented differently. It’s not easy to know which would be faster. So I want to run them both in parallel with the same input:
g(x). When one of them finishes, I have my answer. The other calculation should then be aborted.
I may have more than two functions, or I might have one function that I run simultaneously with different parameters:
f(x,b). Again, whichever is done first is the only one I care about.
Is this possible and, if so, how do I do it?