4 ms·
Re #2 - If you are on Windows, take a look at IOCP as a queuing mechanism. Use one IOC port to queue work for the threads and use another IOC port to submit c
by apankrat 7y ago
Re #2 -
If you are on Windows, take a look at IOCP as a queuing mechanism.
Use one IOC port to queue work for the threads and use another IOC port to submit completed work back to whoever's listening. Worker threads then merely wait for the next completion packet, execute the work and post the packet into the second ("done") port. Dead simple and, due to how IOCP works, with very little overhead.
Strictly speaking, this is not what IOC ports are meant for, but the performance you get out of this is nothing short of amazing and the code ends up being short and simple.
[0] https://docs.microsoft.com/en-us/windows/win32/fileio/i-o-completion-ports https://docs.microsoft.com/en-us/windows/win32/fileio/i-o-co...
- dblohm7 7y agoThat's precisely how the QueueUserWorkItem API is implemented under the hood.