Follows a bunch of nagging from Vladislav :P
This implements a thread pool. Tasks (callables) can be passed in and are executed asynchronously, in workers.
Overall, this should allow replacing most of our direct std::thread usage (the exception is SetupUPnP which must be detachable for now).
Design goals:
- N-1 available threads intended for mostly work-stealing workflow -> maximize CPU usage
Ideally we'll hide the std::thread exception safety ugliness away.(pushed back)- Cancellable &
continuablefutures (semi-pushed back) - Allow getting a dedicated worker (if affinity is desired)
- Low priority queue & regular priority queue
- Hopefully not too remote from the C++ 2X concurrency TS - I haven't actually checked where they are too much on this, so this won't be a 1-1 match.
This capability will be used to rework D14 into something more efficient.