1 #ifndef ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
2 #define ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
8 #include <condition_variable>
10 #include "fhiclcpp/fwd.h"
12 #include "artdaq-core/Data/Fragment.hh"
13 #include "artdaq/TransferPlugins/TransferInterface.hh"
14 #include "artdaq/DAQrate/detail/FragCounter.hh"
15 #include "artdaq-utilities/Plugins/MetricManager.hh"
19 class DataReceiverManager;
20 class FragmentStoreElement;
59 FragmentPtr
recvFragment(
int& rank,
size_t timeout_usec = 0);
112 void runReceiver_(
int);
114 bool fragments_ready_()
const;
116 int get_next_source_()
const;
118 std::atomic<bool> stop_requested_;
120 std::map<int, std::thread> source_threads_;
121 std::map<int, std::unique_ptr<TransferInterface>> source_plugins_;
122 std::set<int> enabled_sources_;
123 std::set<int> suppressed_sources_;
125 std::map<int, FragmentStoreElement> fragment_store_;
127 std::mutex input_cv_mutex_;
128 std::condition_variable input_cv_;
129 std::mutex output_cv_mutex_;
130 std::condition_variable output_cv_;
135 bool suppress_noisy_senders_;
136 size_t suppression_threshold_;
138 size_t receive_timeout_;
159 std::cout <<
"FragmentStoreElement CONSTRUCTOR" << std::endl;
177 std::unique_lock<std::mutex> lk(mutex_);
178 frags_.emplace_front(std::move(frag));
188 std::unique_lock<std::mutex> lk(mutex_);
189 frags_.emplace_back(std::move(frag));
199 std::unique_lock<std::mutex> lk(mutex_);
200 auto current_fragment = std::move(frags_.front());
202 empty_ = frags_.size() == 0;
203 return std::move(current_fragment);
218 mutable std::mutex mutex_;
220 std::atomic<bool> empty_;
229 return recv_frag_count_.
count();
237 return recv_frag_count_.slotCount(rank);
245 return recv_frag_size_.count();
247 #endif //ARTDAQ_DAQRATE_DATATRANSFERMANAGER_HH
void emplace_front(FragmentPtr &&frag)
Add a Fragment to the front of the FragmentStoreElement.
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...
Keep track of the count of Fragments received from a set of sources.
void unsuppressAll()
Re-enable all sources.
void reject_fragment(int source_rank, FragmentPtr frag)
Place the given Fragment back in the FragmentStore (Called when the EventStore is full) ...
bool empty() const
Are any Fragment objects contained in this FragmentStoreElement?
void SetEndOfData(size_t eod)
Set the End-Of-Data marker value for this Receiver.
std::set< int > enabled_sources() const
Get the list of enabled sources.
FragmentPtr recvFragment(int &rank, size_t timeout_usec=0)
Receive a Fragment.
DataReceiverManager(const fhicl::ParameterSet &ps)
DataReceiverManager Constructor.
Receives Fragment objects from one or more DataSenderManager instances using TransferInterface plugin...
size_t slotCount(size_t rank) const
Get the count of Fragment objects received by this DataReceiverManager from a given source...
size_t count() const
Return the count of Fragment objects received by this DataReceiverManager.
size_t GetEndOfData() const
Get the value of the End-Of-Data marker for this Receiver.
FragmentStoreElement()
FragmentStoreElement Constructor.
virtual ~DataReceiverManager()
DataReceiverManager Destructor.
void suppress_source(int source)
Suppress the given source.
FragmentPtr front()
Remove the first Fragment from the FragmentStoreElement and return it.
void start_threads()
Start receiver threads for all enabled sources.
size_t count() const
Get the total number of Fragments received.
size_t byteCount() const
Get the total size of all data recieved by this DataReceiverManager.