|
1 | | -# wait-queue |
2 | | -Multiple producer / multiple consumer (MPMC) thread-safe queue for passing data between threads |
| 1 | +# `wait-queue` is a header-only C++ 20 MPMC (multiple producer / multiple consumer) thread-safe queue for passing data between threads. |
| 2 | + |
| 3 | +# Unit Test and Documentation Generation Workflow Status |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +# Overview |
| 12 | + |
| 13 | +`wait_queue` is a multi-reader, multi-writer FIFO queue for transferring data between threads. It is templatized on the type of data passed through the queue as well as the queue container type. Data is passed with value semantics, either by copying or by moving (as opposed to a queue that transfers data by pointer or reference). The wait queue has both wait and no-wait pop semantics. A fixed size container (e.g. a `ring_span`) can be used, eliminating any and all dynamic memory management (useful in embedded or deterministic environments). Similarly, a circular buffer that only allocates on construction can be used, which eliminates dynamic memory management when pushing or popping values on or off the queue. |
| 14 | + |
| 15 | +A graceful shutdown can be performed using the `request_stop` method (modeled on the C++ 20 `request_stop` from `std::stop_source`). This allows waiting reader threads to be notified for shutdown. Alternatively a `std::stop_token` can be passed in to the `wait_queue` constructor, allowing shutdown from outside of the `wait_queue` object. |
| 16 | + |
| 17 | +`wait_queue` is inspired by code from Anthony Williams' Concurrency in Action book, although heavily modified. |
| 18 | + |
| 19 | +Additional documentation can be found dkfjlkjdlkjklj |
| 20 | + |
| 21 | +# Generated Documentation |
| 22 | + |
| 23 | +The generated Doxygen documentation for `wait_queue` is [here](https://connectivecpp.github.io/presentations/). |
| 24 | + |
| 25 | +# Dependencies |
| 26 | + |
| 27 | +The `wait-queue` header file does not have any third-party dependencies. It uses C++ standard library headers only. The unit test code does have dependencies as noted below. |
| 28 | + |
| 29 | +# C++ Standard |
| 30 | + |
| 31 | +`wait-queue` uses C++ 20 features, including `std::stop_token`, `std::stop_source`, `std::condition_variable_any`, `std::scoped_lock`, and `concepts` / `requires`. |
| 32 | + |
| 33 | +# Supported Compilers |
| 34 | + |
| 35 | +Continuous integration workflows build and unit test on g++ (through Ubuntu), MSVC (through Windows), and clang (through macOS). |
| 36 | + |
| 37 | +# Unit Test Dependencies |
| 38 | + |
| 39 | +The unit test code uses [Catch2](https://github.com/catchorg/Catch2). If the `WAIT_QUEUE_BUILD_TESTS` flag is provided to Cmake (see commands below) the Cmake configure / generate will download the Catch2 library as appropriate using the [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) dependency manager. If Catch2 (v3 or greater) is already installed using a different package manager (such as Conan or vcpkg), the `CPM_USE_LOCAL_PACKAGES` variable can be set which results in `find_package` being attempted. Note that v3 (or later) of Catch2 is required. |
| 40 | + |
| 41 | +The unit test uses two third-party libraries (each is a single header-only file): |
| 42 | + |
| 43 | +- Martin Moene's [`ring-span-lite`](https://github.com/martinmoene/ring-span-lite) |
| 44 | +- Justas Masiulis' [`circular_buffer`](https://github.com/JustasMasiulis/circular_buffer) |
| 45 | + |
| 46 | +Specific versions and / or branches for the dependencies are in `test/CMakeLists.txt`. |
| 47 | + |
| 48 | +# Build and Run Unit Tests |
| 49 | + |
| 50 | +To build and run the unit test program: |
| 51 | + |
| 52 | +First clone the `wait-queue` repository, then create a build directory in parallel to the presentations directory (this is called "out of source" builds, which is recommended), then `cd` (change directory) into the build directory. The CMake commands: |
| 53 | + |
| 54 | +``` |
| 55 | +cmake -D WAIT_QUEUE_BUILD_TESTS:BOOL=ON -D JM_CIRCULAR_BUFFER_BUILD_TESTS:BOOL=OFF ../wait-queue |
| 56 | +
|
| 57 | +cmake --build . |
| 58 | +
|
| 59 | +ctest |
| 60 | +``` |
| 61 | + |
| 62 | +For additional test output, run the unit test individually, for example: |
| 63 | + |
| 64 | +``` |
| 65 | +test/wait_queue_test -s |
| 66 | +``` |
| 67 | + |
| 68 | +The example can be built by adding `-D WAIT_QUEUE_BUILD_EXAMPLES:BOOL=ON` to the CMake configure / generate step. |
| 69 | + |
0 commit comments