This version has a far better implementation of the
wait() function, that has the following guarantees:
- All the closures will be ran at least once, both the
waitconditions, and the
- In case the closures take more than 400ms to execute, no wait will happen, but the closures will be executed again imediatelly.
- In case the evaluation of the closures takes less than 400ms, the time of the closure execution will be substracted from the
wait(): for example if the closures took 250ms, the wait will be only 150ms, to compensate for the run time, so each loop stays at ~400ms.
Here’s the canonical simple google search with our
wait in action: