67 cout <<
"test-con-queue -- demonstrates QueueTheadsPool concurrent processing\n"
69 <<
"Creates a pool of worker threads backed by a shared queue. Each thread\n"
70 <<
"runs one of two event types (Event1 / Event2), both of which sleep for\n"
71 <<
WORK_DELAY_MS <<
" ms to simulate work. The test enqueues items, lets workers\n"
72 <<
"run for a while, then suspends, sleeps, resumes, and finally shuts down.\n"
75 <<
" " <<
argv[0] <<
" <num_threads> <num_items> <secs>\n"
78 <<
" num_threads Number of worker threads to create (positive integer)\n"
79 <<
" num_items Number of integer items to enqueue\n"
80 <<
" secs Seconds to let workers run in each active phase\n"
83 <<
" " <<
argv[0] <<
" 4 100 3\n"
84 <<
" Creates 4 threads, enqueues 100 items, runs for 3 s, suspends,\n"
85 <<
" sleeps 5 s, resumes for another 3 s, then shuts down.\n";
91 cerr <<
"Usage: " <<
argv[0] <<
" <num_threads> <num_items> <secs>" <<
endl;
97 if (
argv[1][0] ==
'-')
109 if (
argv[2][0] ==
'-')
121 if (
argv[3][0] ==
'-')
135 for (
size_t i = 0; i < num_threads; ++i)
145 cout <<
"Inserting " << num_items <<
" to the queue" <<
endl;
146 for (
size_t i = 0; i < num_items; ++i)
148 cout <<
"Inserting " << i <<
endl;
151 cout <<
"Done" <<
endl
153 <<
"Resuming ... " <<
endl;
157 <<
"Sleeping for " <<
secs <<
" seconds" <<
endl;
158 this_thread::sleep_for(chrono::seconds(
secs));
162 <<
"List of event counters" <<
endl;
165 cout <<
" Event count = " << e->get_count() <<
endl;
168 cout <<
"done" <<
endl
170 <<
"Suspending (cooperative: in-flight tasks continue in run())" <<
endl;
172 cout <<
"Done" <<
endl
174 <<
"Sleeping for 5 secs" <<
endl;
175 this_thread::sleep_for(chrono::seconds(5));
176 cout <<
"done" <<
endl
178 <<
"Resuming while other " <<
secs <<
" seconds" <<
endl
181 this_thread::sleep_for(chrono::seconds(
secs));
185 <<
"List of event counters" <<
endl;
188 cout <<
" Event count = " << e->get_count() <<
endl;
191 cout <<
"done" <<
endl
193 <<
"Shutdown" <<
endl;
195 cout <<
"Done" <<
endl;
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
void increment_count() noexcept
Pool of consumer threads form a queue.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Queue-based consumer thread pool.
void run() override
this is a item extracted from the queue
void run() override
this is a item extracted from the queue
static constexpr size_t WORK_DELAY_MS