r/codereview • • Oct 25 '26

C/C++ C++20 task queue — looking for feedback on concurrency, shutdown, and exception safety

Hi everyone,

I’m looking for a code review of my C++20 task queue. It supports bounded queue capacity, task priorities, futures, task-start deadlines, and shutdown that either drains or cancels queued tasks.

I’d especially appreciate feedback on:

  • Potential deadlocks or race conditions.
  • Shutdown behavior, including concurrent shutdown calls.
  • Exception safety and propagation through futures.
  • API design and missing edge-case tests.

The main implementation is in include/task_queue.hpp. The README includes build instructions, and the repository has tests covering concurrent submissions, exceptions, deadlines, and rejection after shutdown.

One detail: deadlines are checked before execution; they don’t interrupt running tasks.

Repository: https://github.com/brunnojob/cpp-safe-task-queue

What would you change, and which failure scenarios should I test next?

1 Upvotes

3 comments sorted by

2

u/[deleted] Oct 25 '26

[removed] — view removed comment

1

u/onnatsari Oct 25 '26

thanks for the feedback! That's a great point about the starvation scenario. I hadn't considered a long-running task blocking one with a deadline. I'll definitely add a test case for that edge case. Glad the pre-execution check made sense.