mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-04-26 01:20:44 +02:00
Rename "writing" to "saving" from ZmqRecvModule
The module should not have a notion of writing - but saving/discarding flag is very useful.
This commit is contained in:
@@ -12,7 +12,7 @@ class ZmqRecvModule
|
||||
RingBuffer& ring_buffer_;
|
||||
const header_map& header_values_;
|
||||
std::atomic_bool is_receiving_;
|
||||
std::atomic_bool is_writing_;
|
||||
std::atomic_bool is_saving_;
|
||||
std::vector<std::thread> receiving_threads_;
|
||||
|
||||
protected:
|
||||
@@ -28,8 +28,8 @@ public:
|
||||
const uint8_t n_receiving_threads);
|
||||
void stop_recv();
|
||||
|
||||
void start_writing();
|
||||
void stop_writing();
|
||||
void start_saving();
|
||||
void stop_saving();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -12,7 +12,7 @@ ZmqRecvModule::ZmqRecvModule(
|
||||
ring_buffer_(ring_buffer),
|
||||
header_values_(header_values),
|
||||
is_receiving_(false),
|
||||
is_writing_(false)
|
||||
is_saving_(false)
|
||||
{}
|
||||
|
||||
void ZmqRecvModule::start_recv(
|
||||
@@ -70,30 +70,30 @@ void ZmqRecvModule::stop_recv()
|
||||
receiving_threads_.clear();
|
||||
}
|
||||
|
||||
void ZmqRecvModule::start_writing()
|
||||
void ZmqRecvModule::start_saving()
|
||||
{
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[ZmqRecvModule::start_writing]";
|
||||
cout << "[ZmqRecvModule::start_saving]";
|
||||
cout << " Enable writing." << endl;
|
||||
#endif
|
||||
|
||||
is_writing_ = true;
|
||||
is_saving_ = true;
|
||||
}
|
||||
|
||||
void ZmqRecvModule::stop_writing()
|
||||
void ZmqRecvModule::stop_saving()
|
||||
{
|
||||
#ifdef DEBUG_OUTPUT
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
cout << "[" << system_clock::now() << "]";
|
||||
cout << "[ZmqRecvModule::stop_writing]";
|
||||
cout << "[ZmqRecvModule::stop_saving]";
|
||||
cout << " Enable writing." << endl;
|
||||
#endif
|
||||
|
||||
is_writing_ = false;
|
||||
is_saving_ = false;
|
||||
}
|
||||
|
||||
void ZmqRecvModule::receive_thread(const string& connect_address)
|
||||
@@ -110,7 +110,7 @@ void ZmqRecvModule::receive_thread(const string& connect_address)
|
||||
// .first and .second = nullptr when no message received
|
||||
// If no message or currently not writing, idle.
|
||||
if (frame.first == nullptr ||
|
||||
!is_writing_.load(memory_order_relaxed)) {
|
||||
!is_saving_.load(memory_order_relaxed)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ TEST(ZmqRecvModule, basic_interaction)
|
||||
uint8_t n_receivers = 4;
|
||||
zmq_recv_module.start_recv("tcp://127.0.0.1:11000", n_receivers);
|
||||
|
||||
zmq_recv_module.start_writing();
|
||||
zmq_recv_module.stop_writing();
|
||||
zmq_recv_module.start_saving();
|
||||
zmq_recv_module.stop_saving();
|
||||
|
||||
zmq_recv_module.stop_recv();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ TEST(ZmqRecvModule, simple_recv)
|
||||
RingBuffer ring_buffer(n_msg);
|
||||
|
||||
ZmqRecvModule zmq_recv_module(ring_buffer, {});
|
||||
zmq_recv_module.start_writing();
|
||||
zmq_recv_module.start_saving();
|
||||
zmq_recv_module.start_recv("tcp://127.0.0.1:11000", 4);
|
||||
|
||||
sender.join();
|
||||
|
||||
Reference in New Issue
Block a user