Skip to content

GorNishanov/conqueue

Repository files navigation

conqueue

clang-14

Supporting material for paper: d2912r0: Concurrent queues and sender/receivers

Experimental implementation of concurrent buffer queue with adding sender/receiver based async_pop / async_push to https://wg21.link/p1958r0. Using reference implementation of sender/receiver from https://github.com/NVIDIA/stdexec.

Inspired by

enum class conqueue_errc { success, empty, full, closed };
class conqueue_error : public system_error { ... };
template <typename T, typename Alloc = std::allocator<T>> class buffer_queue {
public:
  using value_type = T;

  explicit buffer_queue(size_t max_elems, Alloc alloc = Alloc());
  ~buffer_queue() noexcept;

  // observers
  bool is_closed() noexcept;
  size_t capacity() const noexcept;

  // modifiers
  void close() noexcept;

  T pop();
  std::optional<T> pop(std::error_code& ec);
  std::optional<T> try_pop(std::error_code& ec);

  void push(const T& x);
  bool push(const T& x, error_code& ec); // used to be wait_push
  bool try_push(const T& x, error_code& ec);

  void push(T&& x);
  bool push(T&& x, error_code& ec); // used to be wait_push
  bool try_push(T&& x, error_code& ec);

  // async modifiers
  push_sender async_push(const T& x) noexcept(is_nothrow_copy_constructible_v<T>);
  push_sender async_push(T&& x) noexcept(is_nothrow_move_constructible_v<T>);
  pop_sender async_pop() noexcept;
};

About

experimenting with adding async_pop / push to https://wg21.link/P0260R5

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published