Dispatch Queue / Thread Pool implementation for C++11 with built-in C++20 coroutine support.
SharedArrayBuffer support.dispatch_queue.dispatch(f, args...) to dispatch new tasksdispatch_queue.dispatch_main(f, args...) to dispatch "main loop" tasksdispatch_queue.main_loop() manually where appropriate to run queued main loop tasksdispatch_queue.dispatch_tagged(tag, f, args...) to dispatch tagged tasksdispatch_queue::task<T> from dispatch methods are similar to std::shared_future, with the following additions:task.get_state() to get whether task is invalid, pending, ready or failed with exceptiontask.then(f) to add a continuation function that runs when task finishestask.get_exception() to get stored exception_ptrtask<T>::create_ready(T) to create a finished task that in the ready statetask<T>::create_failed(e) to create a finished task that in the failed statetask<T>::create_pending() to create a pending task that can be finished using task.set_value(T) and task.set_exception(e)dispatch_queue::when_all(tasks...) to get a task that finishes when all the passed tasks finishdispatch_queue::when_any(tasks...) to get a task that finishes when any of the passed tasks finishdispatch_queue::parallel_for(f, begin, end, batch_size) or dispatch_queue::parallel_for(f, range, batch_size) to process ranges in paralleldispatch_queue::task<T> as the return value for your coroutinesco_await other tasks to resume the coroutine as the task's continuationco_await dispatch_queue.dispatch() to continue coroutine in a dispatch queue's background loopco_await dispatch_queue.dispatch_main() to continue coroutine in a dispatch queue's main loopco_await dispatch_queue.dispatch_tagged() to continue coroutine in a dispatch queue's background loop using the provided tag-fno-exceptions and -fno-rttiAdd this project using add_subdirectory and link your target to dispatch_queue:
You can pass a functor to the dispatch queue constructor that will run inside worker threads when they initialize. There you can set thread names: