-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix: Bound channel elements per iteration
At the moment, the channel implentation processes as many channel elements as possible every time "process_events" is called. However, in multithreaded cases this can cause the loop to be stuck in the "process_events" section of a channel forever. If one thread keeps sending new elements into the channel while the current thread keeps reading them, it will starve other event sources of running time. This commit fixes this issue by bounding the number of channel elements that can be processed every time "process_events" is called. It chooses the smallest of the following numbers: - The capacity of the channel. - 1024 (chosen because this is also used by async-executor) If the channel is not empty after we have read this number of elements, the underlying source is not triggered. This should make it so the channel is immediately re-polled on the next dispatch. However it gives other sources more time to run. Signed-off-by: John Nunley <[email protected]>
- Loading branch information
Showing
1 changed file
with
91 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters