File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Copyright (c) 2024 by Cliff Green
2+ #
3+ # Distributed under the Boost Software License, Version 1.0.
4+ # (See accompanying file LICENSE.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
5+
6+ cmake_minimum_required ( VERSION 3.14 FATAL_ERROR )
7+
8+ # create project
9+ project ( wait_queue_example LANGUAGES CXX )
10+
11+ # add executable
12+ add_executable ( wait_queue_example wait_queue_example.cpp )
13+ target_compile_features ( wait_queue_example PRIVATE cxx_std_20 )
14+
15+ set ( CMAKE_THREAD_PREFER_PTHREAD TRUE )
16+ set ( THREADS_PREFER_PTHREAD_FLAG TRUE )
17+ find_package ( Threads REQUIRED )
18+
19+ # link dependencies
20+ target_link_libraries ( wait_queue_example PRIVATE
21+ Threads::Threads wait_queue )
22+
Original file line number Diff line number Diff line change 33 * @brief Example code demonstrating use of @c chops::wait_queue.
44 * See @c threaded_wait_shared_demo.cpp for multithreaded example.
55 *
6- * @ingroup example_module
7- *
86 * @author Thurman Gillespy
97 *
108 * Copyright (c)2019 by Thurman Gillespy
119 * 3/22/19
1210 *
11+ * Minor changes May 2024 by Cliff Green to match new @c wait_queue API.
12+ *
1313 * Distributed under the Boost Software License, Version 1.0.
1414 * (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
1515 *
1919 */
2020
2121#include < iostream>
22+ #include < ios> // std::boolalpha
2223#include < cstdlib> // EXIT_SUCCESS
2324#include < string>
2425#include < optional> // std::optional
2829// print queue stats
2930void queueState (const chops::wait_queue<int >& wq) {
3031
32+ std::cout << std::boolalpha;
3133 std::cout << " wait queue contains " << wq.size () << " elements" << std::endl;
32- std::cout << " wait queue is empty: " << ( wq.empty () ? " true " : " false " ) << std::endl;
33- std::cout << " wait queue is open : " << ( wq.is_closed () ? " false " : " true " ) << std::endl;
34+ std::cout << " wait queue is empty: " << wq.empty () << std::endl;
35+ std::cout << " wait queue stop requested : " << wq.stop_requested ( ) << std::endl;
3436 std::cout << std::endl;
3537}
3638
@@ -67,8 +69,6 @@ int main() {
6769 }
6870 printLn ();
6971
70- // all done, close shop
71- wq.close ();
7272 queueState (wq);
7373
7474 return EXIT_SUCCESS ;
You can’t perform that action at this time.
0 commit comments