Ever since its inception, some methods in JobRepository have used event WaitAsync calls with timeouts to mitigate the possibility of a race condition leaving events uncaught. They are set in loops with a 250ms timeout whose exit conditions check the data that the awaited event implies a state for. This is functional and it prevents CPU pinning as intended, but it could surely be better.
This issue marks an official effort to address that.
Pain points in JobRepository:
WaitForEmptyRepositoryAsync waits for _repositoryEmptyEvent. The setting of this this event implies that the number of watched jobs is zero.
GetNextJobAsync waits for _jobsAvailableEvent if there is currently no next job. The setting of this implies that the number of available jobs is non-zero.
Ever since its inception, some methods in
JobRepositoryhave used eventWaitAsynccalls with timeouts to mitigate the possibility of a race condition leaving events uncaught. They are set in loops with a 250ms timeout whose exit conditions check the data that the awaited event implies a state for. This is functional and it prevents CPU pinning as intended, but it could surely be better.This issue marks an official effort to address that.
Pain points in
JobRepository:WaitForEmptyRepositoryAsyncwaits for_repositoryEmptyEvent. The setting of this this event implies that the number of watched jobs is zero.GetNextJobAsyncwaits for_jobsAvailableEventif there is currently no next job. The setting of this implies that the number of available jobs is non-zero.