1
2
3
4
5
6
Use the "Verify Solution" button to get AI feedback on your C++ code.
Implement a FixedSizeThreadPool class in C++. This thread pool should be able to execute submitted tasks asynchronously. The pool should have a fixed number of worker threads that are created upon initialization and persist for the lifetime of the pool. When the FixedSizeThreadPool is destroyed, all pending tasks should be completed, and worker threads should be gracefully shut down.
Your implementation must correctly handle:
The provided starter code has a basic structure but is missing critical synchronization mechanisms and graceful shutdown logic, leading to potential race conditions, busy-waiting, deadlocks, or improper resource management.