21 using Sender = std::function<
22 void(T
const&, boost::asio::basic_yield_context<boost::asio::any_io_executor>)>;
28 bool isSending_{
false};
32 SendingQueue(Sender sender,
size_t maxSize) : sender_{std::move(sender)}, maxSize_{maxSize}
36 std::expected<void, Error>
37 send(T message, boost::asio::yield_context yield)
40 return std::unexpected{error_};
42 if (queue_.size() >= maxSize_) {
43 error_ = boost::asio::error::timed_out;
44 return std::unexpected{error_};
47 queue_.push(std::move(message));
52 while (not queue_.empty() and not error_) {
53 auto const responseToSend = std::move(queue_.front());
57 sender_(responseToSend, yield[writeError]);
63 return std::unexpected{error_};