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_QRECEIVER_HPP_
10#define IOMANAGER_INCLUDE_IOMANAGER_QRECEIVER_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 {
24namespace iomanager {
25
26// QImpl
27template<typename Datatype>
28class QueueReceiverModel : public ReceiverConcept<Datatype>
29{
30public:
31 explicit QueueReceiverModel(ConnectionId const& request);
32
34
36
37 Datatype receive(Receiver::timeout_t timeout) override;
38
39 std::optional<Datatype> try_receive(Receiver::timeout_t timeout) override;
40
41 void add_callback(std::function<void(Datatype&)> callback) override;
42
43 void remove_callback() override;
44
45 // Topics are not used for Queues
46 void subscribe(std::string) override {}
47 void unsubscribe(std::string) override {}
48
49private:
50 std::atomic<bool> m_with_callback{ false };
51 std::function<void(Datatype&)> m_callback;
52 std::unique_ptr<std::thread> m_event_loop_runner;
53 std::shared_ptr<Queue<Datatype>> m_queue;
54};
55
56} // namespace iomanager
57} // namespace dunedaq
58
60
61#endif // IOMANAGER_INCLUDE_IOMANAGER_RECEIVER_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:28
Including Qt Headers.