Dispatch Queue
Dispatch Queue / Thread Pool implementation for C++11 with built-in C++20 coroutine support
 
Loading...
Searching...
No Matches
dispatch_queue.cpp
1#include "../include/dispatch_queue.hpp"
2
3namespace dispatch_queue {
4
8
13
17
19 return worker_pool != nullptr;
20}
21
23 if (worker_pool) {
24 return worker_pool->thread_count();
25 }
26 else {
27 return 0;
28 }
29}
30
31size_t dispatch_queue::size() const {
32 if (worker_pool) {
33 return worker_pool->size();
34 }
35 else {
36 return 0;
37 }
38}
39
41 return size() == 0;
42}
43
45 if (worker_pool) {
46 worker_pool->clear();
47 }
48}
49
51 std::deque<detail::pending_task> main_loop_tasks = worker_pool
52 ? worker_pool->pop_main_loop_tasks()
53 : task_queue.pop_main_loop_tasks();
54 for (auto&& it : main_loop_tasks) {
55 it();
56 }
57}
58
60 if (worker_pool) {
61 worker_pool->wait();
62 }
63}
64
66 clear();
67 worker_pool.reset();
68}
69
70} // end namespace dispatch_queue
void shutdown()
Definition dispatch_queue.cpp:65
bool empty() const
Definition dispatch_queue.cpp:40
int thread_count() const
Definition dispatch_queue.cpp:22
void wait()
Definition dispatch_queue.cpp:59
~dispatch_queue()
Definition dispatch_queue.cpp:14
bool is_threaded() const
Definition dispatch_queue.cpp:18
void clear()
Definition dispatch_queue.cpp:44
void main_loop()
Definition dispatch_queue.cpp:50
size_t size() const
Definition dispatch_queue.cpp:31
dispatch_queue()
Definition dispatch_queue.cpp:5