2 #include "artdaq/RoutingPolicies/PolicyMacros.hh"
3 #include "artdaq/RoutingPolicies/RoutingManagerPolicy.hh"
4 #include "fhiclcpp/ParameterSet.h"
47 int tokenUsagePercent_;
52 , tokenUsagePercent_(ps.get<int>(
"tokens_used_per_table_percent", 50))
58 std::map<int, int> table;
60 for (
auto token : *tokens)
67 int tokensToUse = ceil(tokenCount * tokenUsagePercent_ / 100.0);
73 bool breakCondition =
false;
74 while (table[r.first] > 0)
79 if (tokensUsed >= tokensToUse)
81 breakCondition =
true;
93 for (
auto i = 0; i < r.second; ++i)
95 tokens->push_back(r.first);
A row of the Routing Table.
detail::RoutingPacket GetCurrentTable() override
Apply the policy to the current tokens.
Fragment::sequence_id_t next_sequence_id_
The next sequence ID to be assigned.
std::unique_ptr< std::deque< int > > getTokensSnapshot()
Gets the current token list, used for building Routing Tables.
The interface through which RoutingManagerCore obtains Routing Tables using received Routing Tokens...
void addUnusedTokens(std::unique_ptr< std::deque< int >> tokens)
If necessary, return unused tokens to the token list, for subsequent updates.
~CapacityTestPolicy() override=default
Default virtual Destructor.
std::vector< RoutingPacketEntry > RoutingPacket
A RoutingPacket is simply a vector of RoutingPacketEntry objects. It is not suitable for network tran...
A RoutingManagerPolicy which tries to fully load the first receiver, then the second, and so on.
CapacityTestPolicy(const fhicl::ParameterSet &ps)
CapacityTestPolicy Constructor.