[MS] How can I schedule work on a thread pool with low latency? - devamazonaws.blogspot.com
A customer had a callback that was used to report data being produced by a hardware device. The rule for the callback is that it has to return quickly so that the code wouldn't miss the next batch of data because the device itself has a very small buffer: If they spend too much time in the callback, the buffer will overflow and data will be lost. To avoid clogging the receiving thread, the customer queued a work item to the thread pool to process the data that was just received. However, they found that sometimes, the work item doesn't run immediately but rather has a 100ms latency. But their program needs to process the data within 20ms. Is there a way to set a deadline on a thread pool work item, so that the system will make sure that it runs before a certain period of time elapses? As I've noted before, the thread pool is designed for throughput, not latency . There is no option to set a deadline on a work item. One reason why the thread pool is being slow to dispatc...