Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stopped spinning in CurrentThreadExecutor.run_until_future()
Rather that spinning on - check for work, non-blocking - check the future - sleep briefly We can register a done callback on the future, which will be called with the future itself as an arugment. Registering our task queue's `put()` method lets us use the future itself as a sentinal value. Now we can use `queue.get()` in blocking fashion. If we find the job is the future we're waiting on, we're done getting tasks and we return, otherwise we run the job and go back to blocking on `queue.get()` for more tasks. This noticeably cuts down on CPU usage in run_until_future().
- Loading branch information