DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
QueueReceiverModel.hpp
Go to the documentation of this file.
1
9#ifndef IOMANAGER_INCLUDE_IOMANAGER_QUEUE_QUEUERECEIVERMODEL_HPP_
10#define IOMANAGER_INCLUDE_IOMANAGER_QUEUE_QUEUERECEIVERMODEL_HPP_
11
14
15#include "logging/Logging.hpp"
16
17#include <atomic>
18#include <memory>
19#include <optional>
20#include <string>
21#include <thread>
22
23namespace dunedaq::iomanager {
24
25// QImpl
26template<typename Datatype>
27class QueueReceiverModel : public ReceiverConcept<Datatype>
28{
29public:
30 explicit QueueReceiverModel(ConnectionId const& request);
31
33
35
36 Datatype receive(Receiver::timeout_t timeout) override;
37
38 std::optional<Datatype> try_receive(Receiver::timeout_t timeout) override;
39
40 void add_callback(std::function<void(Datatype&)> callback) override;
41
42 void remove_callback() override;
43
44 // Topics are not used for Queues
45 void subscribe(std::string) override {}
46 void unsubscribe(std::string) override {}
47
48private:
49 std::atomic<bool> m_with_callback{ false };
50 std::function<void(Datatype&)> m_callback;
51 std::unique_ptr<std::thread> m_event_loop_runner;
52 std::shared_ptr<Queue<Datatype>> m_queue;
53};
54
55} // namespace dunedaq::iomanager
56
58
59#endif // IOMANAGER_INCLUDE_IOMANAGER_QUEUE_QUEUERECEIVERMODEL_HPP_
std::function< void(Datatype &)> m_callback
QueueReceiverModel(ConnectionId const &request)
std::shared_ptr< Queue< Datatype > > m_queue
std::unique_ptr< std::thread > m_event_loop_runner
void add_callback(std::function< void(Datatype &)> callback) override
std::optional< Datatype > try_receive(Receiver::timeout_t timeout) override
Datatype receive(Receiver::timeout_t timeout) override
std::chrono::milliseconds timeout_t
Definition Receiver.hpp:27