ActivityPtr previous_activity_;
ActivityPtr current_activity_;
+ inline static xbt::signal<void(Task*)> on_start;
+ xbt::signal<void(Task*)> on_this_start;
+ inline static xbt::signal<void(Task*)> on_completion;
+ xbt::signal<void(Task*)> on_this_completion;
+
protected:
explicit Task(const std::string& name);
- virtual ~Task() = default;
+ virtual ~Task() = default;
virtual void fire();
void complete();
- void set_current_activity (ActivityPtr a) { current_activity_ = a; }
+ void set_current_activity(ActivityPtr a) { current_activity_ = a; }
- inline static xbt::signal<void(Task*)> on_start;
- xbt::signal<void(Task*)> on_this_start;
- inline static xbt::signal<void(Task*)> on_completion;
- xbt::signal<void(Task*)> on_this_completion;
-
public:
const std::string& get_name() const { return name_; }
const char* get_cname() const { return name_.c_str(); }
int aid_value = value_of_state_;
const Transition* transition = actor.get_transition(actor.get_times_considered()).get();
-
- const CommRecvTransition* cast_recv = dynamic_cast<CommRecvTransition const*>(transition);
- if (cast_recv != nullptr) {
- if (mailbox_.count(cast_recv->get_mailbox()) > 0 and
- mailbox_.at(cast_recv->get_mailbox()) > 0) {
- aid_value--; // This means we have waiting recv corresponding to this recv
- } else {
+
+ if (auto const* cast_recv = dynamic_cast<CommRecvTransition const*>(transition)) {
- if (mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) > 0) {
- aid_value--; // This means we have waiting recv corresponding to this recv
- } else {
- aid_value++;
- }
++ if (mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) > 0) {
++ aid_value--; // This means we have waiting recv corresponding to this recv
++ } else {
+ aid_value++;
- }
++ }
}
-
- const CommSendTransition* cast_send = dynamic_cast<CommSendTransition const*>(transition);
- if (cast_send != nullptr) {
- if (mailbox_.count(cast_send->get_mailbox()) > 0 and
- mailbox_.at(cast_send->get_mailbox()) < 0) {
- aid_value--; // This means we have waiting recv corresponding to this send
- }else {
- aid_value++;
- }
+
+ if (auto const* cast_send = dynamic_cast<CommSendTransition const*>(transition)) {
- if (mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) < 0) {
- aid_value--; // This means we have waiting recv corresponding to this send
- } else {
- aid_value++;
- }
++ if (mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) < 0) {
++ aid_value--; // This means we have waiting recv corresponding to this send
++ } else {
++ aid_value++;
++ }
}
-
+
if (aid_value < min_found.second)
min_found = std::make_pair(aid, aid_value);
}
int aid_value = value_of_state_;
const Transition* transition = actor.get_transition(actor.get_times_considered()).get();
- const CommRecvTransition* cast_recv = dynamic_cast<CommRecvTransition const*>(transition);
- if (cast_recv != nullptr) {
- if ((mailbox_.count(cast_recv->get_mailbox()) > 0 and
- mailbox_.at(cast_recv->get_mailbox()) <= 0) or mailbox_.count(cast_recv->get_mailbox()) == 0)
- aid_value--; // This means we don't have waiting recv corresponding to this recv
- else
- aid_value++;
+ if (auto const* cast_recv = dynamic_cast<CommRecvTransition const*>(transition)) {
- if ((mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) <= 0) ||
- mailbox_.count(cast_recv->get_mailbox()) == 0)
- aid_value--; // This means we don't have waiting recv corresponding to this recv
- else
- aid_value++;
++ if ((mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) <= 0) ||
++ mailbox_.count(cast_recv->get_mailbox()) == 0)
++ aid_value--; // This means we don't have waiting recv corresponding to this recv
++ else
++ aid_value++;
}
- const CommSendTransition* cast_send = dynamic_cast<CommSendTransition const*>(transition);
- if (cast_send != nullptr) {
- if ((mailbox_.count(cast_send->get_mailbox()) > 0 and
- mailbox_.at(cast_send->get_mailbox()) >= 0) or mailbox_.count(cast_send->get_mailbox()) == 0)
- aid_value--;
- else
- aid_value++;
+ if (auto const* cast_send = dynamic_cast<CommSendTransition const*>(transition)) {
- if ((mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) >= 0) ||
- mailbox_.count(cast_send->get_mailbox()) == 0)
- aid_value--;
- else
- aid_value++;
++ if ((mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) >= 0) ||
++ mailbox_.count(cast_send->get_mailbox()) == 0)
++ aid_value--;
++ else
++ aid_value++;
}
-
+
if (aid_value < min_found.second)
min_found = std::make_pair(aid, aid_value);
}
{
unsigned long count = 0;
for (auto& [_, actor] : actors_to_run_)
- if (actor.is_enabled() and not actor.is_done()) {
- if (actor.is_enabled() && not actor.is_done()) {
-- actor.mark_todo();
-- count++;
-- }
++ if (actor.is_enabled() && not actor.is_done()) {
++ actor.mark_todo();
++ count++;
++ }
return count;
}
chosen = xbt::random::uniform_int(0, possibilities-1);
for (auto const& [aid, actor] : actors_to_run_) {
- if (((not actor.is_todo()) and must_be_todo) or actor.is_done() or (not actor.is_enabled()))
- if (((not actor.is_todo()) && must_be_todo) || actor.is_done() || (not actor.is_enabled()))
++ if (((not actor.is_todo()) && must_be_todo) || actor.is_done() || (not actor.is_enabled()))
continue;
if (chosen == 0) {
return std::make_pair(aid, valuation.at(aid));
"model-check/strategy",
"Specify the the kind of heuristic to use for guided model-checking",
"none",
- {{"none", "No specific strategy: simply pick the first available transistion and act as a DFS."},
+ {{"none", "No specific strategy: simply pick the first available transition and act as a DFS."},
{"max_match_comm", "Try to minimize the number of in-fly communication by appairing matching send and receive."},
-- {"min_match_comm", "Try to maximize the number of in-fly communication by not appairing matching send and receive."},
-- {"uniform", "No specific strategy: choices are made randomly based on a uniform sampling."}
-- }};
++ {"min_match_comm",
++ "Try to maximize the number of in-fly communication by not appairing matching send and receive."},
++ {"uniform", "No specific strategy: choices are made randomly based on a uniform sampling."}}};
simgrid::config::Flag<int> _sg_mc_random_seed{"model-check/rand-seed",
"give a specific random seed to initialize the uniform distribution", 0,
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;
+ bool enough_tokens = true;
for (auto const& [key, val] : predecessors_)
if (val < 1) {
enough_tokens = false;
return tokens_received_.front()[t];
}
-void Task::fire() {
+void Task::fire()
+{
on_this_start(this);
on_start(this);
- working_ = true;
+ working_ = true;
queued_firings_ = std::max(queued_firings_ - 1, 0);
- if (tokens_received_.size() > 0)
+ if (not tokens_received_.empty())
tokens_received_.pop_front();
}