Skip to content

Merging develop to main #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

`wait_queue` is a multi-reader, multi-writer FIFO thread-safe wait queue (often called MPMC for multiple producer / multiple consumer) 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.

Thanks go to [Louis Langholtz](https://github.com/louis-langholtz) for adding DBC (Design by Contract) asserts and comments.

## Generated Documentation

The generated Doxygen documentation for `wait_queue` is [here](https://connectivecpp.github.io/wait-queue/).
Expand Down
18 changes: 6 additions & 12 deletions include/queue/wait_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ class wait_queue {
*/
wait_queue()
// noexcept(std::is_nothrow_constructible<Container>::value)
: m_stop_src(std::stop_source{}), m_stop_tok((*m_stop_src).get_token())
{
: m_stop_src(std::stop_source{}), m_stop_tok((*m_stop_src).get_token()) {
assert(empty());
assert(size() == size_type(0));
assert(!stop_requested());
Expand All @@ -210,8 +209,7 @@ class wait_queue {
*/
wait_queue(std::stop_token stop_tok)
// noexcept(std::is_nothrow_constructible<Container>::value)
: m_stop_tok(stop_tok)
{
: m_stop_tok(stop_tok) {
assert(empty());
assert(size() == size_type(0));
}
Expand Down Expand Up @@ -242,8 +240,7 @@ class wait_queue {
wait_queue(Iter beg, Iter end)
// noexcept(std::is_nothrow_constructible<Container, Iter, Iter>::value)
: m_stop_src(std::stop_source{}), m_stop_tok((*m_stop_src).get_token()),
m_data_queue(beg, end)
{
m_data_queue(beg, end) {
assert(empty() == (beg == end));
assert((size() == size_type(0)) == (beg == end)); // std::distance constrains beg, end.
}
Expand All @@ -264,8 +261,7 @@ class wait_queue {
template <typename Iter>
wait_queue(std::stop_token stop_tok, Iter beg, Iter end)
// noexcept(std::is_nothrow_constructible<Container, Iter, Iter>::value)
: m_stop_tok(stop_tok), m_data_queue(beg, end)
{
: m_stop_tok(stop_tok), m_data_queue(beg, end) {
assert(empty() == (beg == end));
assert((size() == size_type(0)) == (beg == end)); // std::distance constrains beg, end.
}
Expand Down Expand Up @@ -295,8 +291,7 @@ class wait_queue {
wait_queue(size_type sz)
// noexcept(std::is_nothrow_constructible<Container, size_type>::value)
: m_stop_src(std::stop_source{}), m_stop_tok((*m_stop_src).get_token()),
m_data_queue(sz)
{
m_data_queue(sz) {
assert((sz != size_type(0)) || empty());
assert((size() == size_type(0)) || (size() == sz));
}
Expand All @@ -315,8 +310,7 @@ class wait_queue {
*/
wait_queue(std::stop_token stop_tok, size_type sz)
// noexcept(std::is_nothrow_constructible<Container, size_type>::value)
: m_stop_tok((*m_stop_src).get_token()), m_data_queue(sz)
{
: m_stop_tok((*m_stop_src).get_token()), m_data_queue(sz) {
assert((sz != size_type(0)) || empty());
assert((size() == size_type(0)) || (size() == sz));
}
Expand Down
Loading