40 bool m_write_in_progress;
42 mutable std::mutex m_mutex;
45 using lk_guard = std::lock_guard<std::mutex>;
50 m_write_in_progress =
false;
54 enum write_status { io_stopped, queued, write_started };
59 m_io_started(
false), m_write_in_progress(
false), m_outq(), m_mutex() { }
62 auto get_output_queue_stats()
const noexcept {
64 return m_outq.get_queue_stats();
67 bool is_io_started()
const noexcept {
72 bool set_io_started()
noexcept {
74 return m_io_started ? false : (m_io_started =
true,
true);
77 bool set_io_stopped()
noexcept {
79 return m_io_started ? (m_io_started =
false,
true) :
false;
83 bool is_write_in_progress()
const noexcept {
85 return m_write_in_progress;
88 void clear()
noexcept {
96 write_status start_write(
const E& elem, F&& func) {
102 if (m_write_in_progress) {
103 m_outq.add_element(elem);
106 m_write_in_progress =
true;
108 return write_started;
111 template <
typename F>
112 void write_next_elem(F&& func) {
113 lk_guard lg(m_mutex);
118 auto elem = m_outq.get_next_element();
120 m_write_in_progress =
false;
123 m_write_in_progress =
true;