GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • src
  • dispatch_queue.cpp

This view

  • Original page
  • New address

GeezerVison is showing gilzoide.github.io — Dispatch Queue: src/dispatch_queue.cpp Source File

Dispatch Queue
Dispatch Queue / Thread Pool implementation for C++11 with built-in C++20 coroutine support
 
Loading...
Searching...
No Matches
dispatch_queue.cpp
Go to the documentation of this file.
1#include "../include/dispatch_queue.hpp"
2
3namespace dispatch_queue {
4
5dispatch_queue::dispatch_queue()
6{
7}
8
9dispatch_queue::dispatch_queue(int thread_count)
10 : dispatch_queue(thread_count, [](int){})
11{
12}
13
14dispatch_queue::~dispatch_queue() {
15 shutdown();
16}
17
18bool dispatch_queue::is_threaded() const {
19 return worker_pool != nullptr;
20}
21
22int dispatch_queue::thread_count() const {
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
40bool dispatch_queue::empty() const {
41 return size() == 0;
42}
43
44void dispatch_queue::clear() {
45 if (worker_pool) {
46 worker_pool->clear();
47 }
48}
49
50void dispatch_queue::main_loop() {
51 auto 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
59void dispatch_queue::wait() {
60 if (worker_pool) {
61 worker_pool->wait();
62 }
63}
64
65void dispatch_queue::shutdown() {
66 clear();
67 worker_pool.reset();
68}
69
70} // end namespace dispatch_queue
dispatch_queue::dispatch_queue::shutdown
void shutdown()
Definition dispatch_queue.cpp:65
dispatch_queue::dispatch_queue::empty
bool empty() const
Definition dispatch_queue.cpp:40
dispatch_queue::dispatch_queue::thread_count
int thread_count() const
Definition dispatch_queue.cpp:22
dispatch_queue::dispatch_queue::wait
void wait()
Definition dispatch_queue.cpp:59
dispatch_queue::dispatch_queue::~dispatch_queue
~dispatch_queue()
Definition dispatch_queue.cpp:14
dispatch_queue::dispatch_queue::is_threaded
bool is_threaded() const
Definition dispatch_queue.cpp:18
dispatch_queue::dispatch_queue::clear
void clear()
Definition dispatch_queue.cpp:44
dispatch_queue::dispatch_queue::main_loop
void main_loop()
Definition dispatch_queue.cpp:50
dispatch_queue::dispatch_queue::size
size_t size() const
Definition dispatch_queue.cpp:31
dispatch_queue::dispatch_queue::dispatch_queue
dispatch_queue()
Definition dispatch_queue.cpp:5
dispatch_queue.hpp
dispatch_queue
Definition dispatch_queue.hpp:19
  • src
  • dispatch_queue.cpp
  • Generated by doxygen 1.13.2
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.