1 #ifndef DOCWIRE_MESSAGE_COUNTERS_H
2 #define DOCWIRE_MESSAGE_COUNTERS_H
5 #include "document_elements.h"
14 bool all_failed()
const {
15 return attempts > 0 && successes == 0;
19 inline bool is_framing_message(
const message_base& msg) {
23 msg.is<std::exception_ptr>();
26 inline message_callbacks make_counted_message_callbacks(
const message_callbacks& original, message_counters& counters) {
27 auto wrapper = [&original, &counters](message_ptr msg,
bool is_back) -> continuation {
28 bool is_framing = is_framing_message(*msg);
29 if (!is_framing) counters.attempts++;
30 auto c = is_back ? original.back(std::move(msg)) : original.further(std::move(msg));
31 if (!is_framing) counters.successes++;
35 return message_callbacks {
36 .m_further = [wrapper](message_ptr msg) {
return wrapper(std::move(msg),
false); },
37 .m_back = [wrapper](message_ptr msg) {
return wrapper(std::move(msg),
true); }
The main namespace for the DocWire SDK.