1 #include "artdaq/Application/Routing/RoutingMasterPolicy.hh"
2 #include <fhiclcpp/ParameterSet.h>
9 auto receiver_ranks = ps.get<std::vector<int>>(
"receiver_ranks");
10 receiver_ranks_.insert(receiver_ranks.begin(), receiver_ranks.end());
15 if (!receiver_ranks_.count(rank))
return;
16 TRACE(10,
"RoutingMasterPolicy::AddReceiverToken BEGIN");
17 std::unique_lock<std::mutex> lk(tokens_mutex_);
18 for (
unsigned i = 0; i < new_slots_free; ++i)
20 tokens_.push_back(rank);
22 if (tokens_.size() > max_token_count_) max_token_count_ = tokens_.size();
23 TRACE(10,
"RoutingMasterPolicy::AddReceiverToken END");
28 TRACE(10,
"RoutingMasterPolicy::getTokensSnapshot BEGIN");
29 std::unique_lock<std::mutex> lk(tokens_mutex_);
30 auto out = std::make_unique<std::deque<int>>(tokens_);
32 TRACE(10,
"RoutingMasterPolicy::getTokensSnapshot END");
38 std::unique_lock<std::mutex> lk(tokens_mutex_);
39 for (
auto token = tokens.get()->rbegin(); token != tokens.get()->rend(); ++token)
41 tokens_.push_front(*token);
43 if (tokens_.size() > max_token_count_) max_token_count_ = tokens_.size();
void AddReceiverToken(int rank, unsigned new_slots_free)
Add a token to the token list.
std::unique_ptr< std::deque< int > > getTokensSnapshot()
Gets the current token list, used for building Routing Tables.
void addUnusedTokens(std::unique_ptr< std::deque< int >> tokens)
If necessary, return unused tokens to the token list, for subsequent updates.
RoutingMasterPolicy(fhicl::ParameterSet ps)
RoutingMasterPolicy Constructor.