1 #ifndef ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
2 #define ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
7 #include <condition_variable>
9 #include "fhiclcpp/fwd.h"
11 #include "artdaq-core/Data/Fragment.hh"
12 #include "artdaq/TransferPlugins/TransferInterface.hh"
13 #include "artdaq/DAQrate/detail/FragCounter.hh"
14 #include "artdaq-utilities/Plugins/MetricManager.hh"
18 class FragmentReceiverManager;
19 class FragmentStoreElement;
58 FragmentPtr
recvFragment(
int& rank,
size_t timeout_usec = 0);
91 void runReceiver_(
int);
93 bool fragments_ready_()
const;
95 int get_next_source_()
const;
97 std::atomic<bool> stop_requested_;
99 std::map<int, boost::thread> source_threads_;
100 std::map<int, std::unique_ptr<TransferInterface>> source_plugins_;
101 std::set<int> enabled_sources_;
103 std::map<int, FragmentStoreElement> fragment_store_;
105 std::mutex input_cv_mutex_;
106 std::condition_variable input_cv_;
107 std::mutex output_cv_mutex_;
108 std::condition_variable output_cv_;
113 bool suppress_noisy_senders_;
114 size_t suppression_threshold_;
116 size_t receive_timeout_;
137 std::cout <<
"FragmentStoreElement CONSTRUCTOR" << std::endl;
155 std::unique_lock<std::mutex> lk(mutex_);
156 frags_.emplace_front(std::move(frag));
166 std::unique_lock<std::mutex> lk(mutex_);
167 frags_.emplace_back(std::move(frag));
177 std::unique_lock<std::mutex> lk(mutex_);
178 auto current_fragment = std::move(frags_.front());
180 empty_ = frags_.size() == 0;
181 return std::move(current_fragment);
196 mutable std::mutex mutex_;
198 std::atomic<bool> empty_;
207 return recv_frag_count_.
count();
215 return recv_frag_count_.slotCount(rank);
223 return recv_frag_size_.count();
225 #endif //ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
void start_threads()
Start receiver threads for all enabled sources.
void emplace_front(FragmentPtr &&frag)
Add a Fragment to the front of the FragmentStoreElement.
size_t byteCount() const
Get the total size of all data recieved by this FragmentReceiverManager.
void emplace_back(FragmentPtr &&frag)
Add a Fragment to the end of the FragmentStoreElement.
This class contains tracking information for all Fragment objects which have been received from a spe...
size_t count() const
Return the count of Fragment objects received by this FragmentReceiverManager.
virtual ~FragmentReceiverManager()
FragmentReceiverManager Destructor.
Receives Fragment objects from one or more DataSenderManager instances using TransferInterface plugin...
Keep track of the count of Fragments received from a set of sources.
bool empty() const
Are any Fragment objects contained in this FragmentStoreElement?
FragmentReceiverManager(const fhicl::ParameterSet &ps)
FragmentReceiverManager Constructor.
void SetEndOfData(size_t eod)
Set the End-Of-Data marker value for this Receiver.
FragmentPtr recvFragment(int &rank, size_t timeout_usec=0)
Receive a Fragment.
size_t slotCount(size_t rank) const
Get the count of Fragment objects received by this FragmentReceiverManager from a given source...
size_t GetEndOfData() const
Get the value of the End-Of-Data marker for this Receiver.
FragmentStoreElement()
FragmentStoreElement Constructor.
FragmentPtr front()
Remove the first Fragment from the FragmentStoreElement and return it.
size_t count() const
Get the total number of Fragments received.
std::set< int > enabled_sources() const
Get the list of enabled sources.