Starting a thread per task is slow and unbounded. A worker pool starts a fixed number of threads once; each loops forever taking tasks from a shared queue and running them. Submitting a task is just a push.
Three details decide whether a pool is correct. Shutdown: the destructor sets a stopping_ flag under the lock, wakes every worker with notify_all, and joins them; a worker exits only when it is stopping and the queue is empty, so no submitted task is lost. Never run a task while holding the queue lock, or the pool runs one task at a time. Results: wrap the callable in a std::packaged_task (held by a std::shared_ptr, because std::function needs a copyable callable) and return its future; exceptions travel through the future too.
Beyond that, real pools add ways to wait until all work is done and keep a worker alive when one task throws. Sizing is usually one worker per core, which the simulator cannot show: here threads take turns on one core.
Threads here are simulated. Your program runs on one real thread while a scheduler switches between your threads at shared reads and writes, locks, atomic operations, waits, yields and sleeps, and every test runs under 12 different schedules. The order things can happen in, races at those points and deadlocks are faithful. Real parallel speed-up and weak memory-order effects are not.
A worker: wait, take a task, unlock, run it.