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_;
102 std::set<int> running_sources_;
104 std::map<int, FragmentStoreElement> fragment_store_;
106 std::mutex input_cv_mutex_;
107 std::condition_variable input_cv_;
108 std::mutex output_cv_mutex_;
109 std::condition_variable output_cv_;
114 bool suppress_noisy_senders_;
115 size_t suppression_threshold_;
117 size_t receive_timeout_;
118 mutable int last_source_;
139 std::cout <<
"FragmentStoreElement CONSTRUCTOR" << std::endl;
157 std::unique_lock<std::mutex> lk(mutex_);
158 frags_.emplace_front(std::move(frag));
168 std::unique_lock<std::mutex> lk(mutex_);
169 frags_.emplace_back(std::move(frag));
179 std::unique_lock<std::mutex> lk(mutex_);
180 auto current_fragment = std::move(frags_.front());
182 empty_ = frags_.size() == 0;
183 return current_fragment;
201 size_t size()
const {
return frags_.size(); }
204 mutable std::mutex mutex_;
206 std::atomic<bool> empty_;
215 return recv_frag_count_.
count();
223 return recv_frag_count_.slotCount(rank);
231 return recv_frag_size_.count();
233 #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.
size_t size() const
Get the number of Fragments stored in this FragmentStoreElement.
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.