// Add a function to be called before each firing of comm0
// This function modifies the graph of tasks by adding or removing
// successors to comm0
- comm0->on_this_start_cb([comm0, exec1, exec2, jupiter, fafard](sg4::Task*) {
+ comm0->on_this_start_cb([comm0, exec1, exec2, jupiter, fafard](const sg4::Task*) {
static int count = 0;
if (count % 2 == 0) {
comm0->set_destination(jupiter);
virtual std::pair<aid_t, int> best_transition(bool must_be_todo) const = 0;
/** Returns the best transition among those that should be interleaved. */
- std::pair<aid_t, int> next_transition() { return best_transition(true); }
+ std::pair<aid_t, int> next_transition() const { return best_transition(true); }
/** Allows for the strategy to update its fields knowing that the actor aid will
* be executed and a children strategy will then be created. */
#include "src/mc/transition/Transition.hpp"
#include "xbt/random.hpp"
-#define MAX_RAND 100000
-
namespace simgrid::mc {
/** Guiding strategy that valuate states randomly */
class UniformStrategy : public Strategy {
+ static constexpr int MAX_RAND = 100000;
+
std::map<aid_t, int> valuation;
public:
}
void copy_from(const Strategy* strategy) override
{
- for (auto& [aid, _] : actors_to_run_)
+ for (auto const& [aid, _] : actors_to_run_)
valuation[aid] = xbt::random::uniform_int(0, MAX_RAND);
}
void Task::receive(Task* source)
{
XBT_DEBUG("Task %s received a token from %s", name_.c_str(), source->name_.c_str());
- auto source_count = predecessors_[source]++;
+ auto source_count = predecessors_[source];
+ predecessors_[source]++;
if (tokens_received_.size() <= queued_firings_ + source_count)
- tokens_received_.push_back({});
+ tokens_received_.emplace_back();
tokens_received_[queued_firings_ + source_count][source] = source->token_;
bool enough_tokens = true;
for (auto const& [key, val] : predecessors_)
on_start(this);
working_ = true;
queued_firings_ = std::max(queued_firings_ - 1, 0);
- if (tokens_received_.size() > 0)
+ if (not tokens_received_.empty())
tokens_received_.pop_front();
}