XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count());
});
- // Enqueue two executions for task exec1
- exec1->enqueue_execs(2);
+ // Enqueue two firings for task exec1
+ exec1->enqueue_firings(2);
// Start the simulation
e.run();
XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count());
});
- // Enqueue two executions for task exec1
- exec1->enqueue_execs(2);
+ // Enqueue two firings for task exec1
+ exec1->enqueue_firings(2);
// Start the simulation
e.run();
t->set_amount(*data * 10);
});
- // Enqueue executions for tasks without predecessors
- SA->enqueue_execs(5);
- SB->enqueue_execs(5);
+ // Enqueue firings for tasks without predecessors
+ SA->enqueue_firings(5);
+ SB->enqueue_firings(5);
// Add a function to be called when tasks end for log purpose
sg4::Task::on_completion_cb([]
XBT_INFO("Task %s finished (%d)", t->get_name().c_str(), t->get_count());
});
- // Add a function to be called before each executions of comm0
+ // 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*) {
count++;
});
- // Enqueue four executions for task comm0
- comm0->enqueue_execs(4);
+ // Enqueue four firings for task comm0
+ comm0->enqueue_firings(4);
// Start the simulation
e.run();
{
XBT_INFO("--- Small load ---");
for (int i = 0; i < 3; i++) {
- t->enqueue_execs(1);
+ t->enqueue_firings(1);
sg4::this_actor::sleep_for(100);
}
sg4::this_actor::sleep_until(1000);
XBT_INFO("--- Heavy load ---");
for (int i = 0; i < 3; i++) {
- t->enqueue_execs(1);
+ t->enqueue_firings(1);
sg4::this_actor::sleep_for(1);
}
}
# Add a function to be called when tasks end for log purpose
Task.on_completion_cb(callback)
- # Enqueue two executions for task exec1
- exec1.enqueue_execs(2)
+ # Enqueue two firings for task exec1
+ exec1.enqueue_firings(2)
# runs the simulation
e.run()
# Add a function to be called when tasks end for log purpose
Task.on_completion_cb(callback)
- # Enqueue two executions for task exec1
- exec1.enqueue_execs(2)
+ # Enqueue two firings for task exec1
+ exec1.enqueue_firings(2)
# runs the simulation
e.run()
# Add a function to be called when tasks end for log purpose
Task.on_completion_cb(callback)
- # Add a function to be called before each executions of comm0
+ # 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(lambda t: switch(t, [jupiter, fafard], [exec1,exec2]))
- # Enqueue two executions for task exec1
- comm0.enqueue_execs(4)
+ # Enqueue two firings for task exec1
+ comm0.enqueue_firings(4)
# runs the simulation
e.run()
def variable_load(t):
print('--- Small load ---')
for _ in range(3):
- t.enqueue_execs(1)
+ t.enqueue_firings(1)
this_actor.sleep_for(100)
this_actor.sleep_for(1000)
print('--- Heavy load ---')
for _ in range(3):
- t.enqueue_execs(1)
+ t.enqueue_firings(1)
this_actor.sleep_for(1)
if __name__ == '__main__':
class Task {
std::string name_;
double amount_;
- int queued_execs_ = 0;
+ int queued_firings_ = 0;
int count_ = 0;
bool working_ = false;
void remove_all_successors();
const std::set<Task*>& get_successors() const { return successors_; }
- void enqueue_execs(int n);
+ void enqueue_firings(int n);
/** Add a callback fired before this task activity starts */
void on_this_start_cb(const std::function<void(Task*)>& func){ on_this_start.connect(func); }
.def_property_readonly("count", &Task::get_count, "The execution count of this task (read-only).")
.def_property_readonly("successors", &Task::get_successors, "The successors of this task (read-only).")
.def_property("amount", &Task::get_amount, &Task::set_amount, "The amount of work to do for this task.")
- .def("enqueue_execs", py::overload_cast<int>(&Task::enqueue_execs), py::call_guard<py::gil_scoped_release>(),
- py::arg("n"), "Enqueue executions for this task.")
+ .def("enqueue_firings", py::overload_cast<int>(&Task::enqueue_firings), py::call_guard<py::gil_scoped_release>(),
+ py::arg("n"), "Enqueue firings for this task.")
.def("add_successor", py::overload_cast<TaskPtr>(&Task::add_successor), py::call_guard<py::gil_scoped_release>(),
py::arg("op"), "Add a successor to this task.")
.def("remove_successor", py::overload_cast<TaskPtr>(&Task::remove_successor),
*/
bool Task::ready_to_run() const
{
- return not working_ && queued_execs_ > 0;
+ return not working_ && queued_firings_ > 0;
}
/**
{
XBT_DEBUG("Task %s received a token from %s", name_.c_str(), source->name_.c_str());
auto source_count = predecessors_[source]++;
- if (tokens_received_.size() <= queued_execs_ + source_count)
+ if (tokens_received_.size() <= queued_firings_ + source_count)
tokens_received_.push_back({});
- tokens_received_[queued_execs_ + source_count][source] = source->token_;
+ tokens_received_[queued_firings_ + source_count][source] = source->token_;
bool enough_tokens = true;
for (auto const& [key, val] : predecessors_)
if (val < 1) {
if (enough_tokens) {
for (auto& [key, val] : predecessors_)
val--;
- enqueue_execs(1);
+ enqueue_firings(1);
}
}
fire();
}
-/** @param n The number of executions to enqueue.
- * @brief Enqueue executions.
- * @note Immediatly starts an execution if possible.
+/** @param n The number of firings to enqueue.
+ * @brief Enqueue firing.
+ * @note Immediatly fire an activity if possible.
*/
-void Task::enqueue_execs(int n)
+void Task::enqueue_firings(int n)
{
simgrid::kernel::actor::simcall_answered([this, n] {
- queued_execs_ += n;
+ queued_firings_ += n;
if (ready_to_run())
fire();
});
on_this_start(this);
on_start(this);
working_ = true;
- queued_execs_ = std::max(queued_execs_ - 1, 0);
+ queued_firings_ = std::max(queued_firings_ - 1, 0);
if (tokens_received_.size() > 0)
tokens_received_.pop_front();
}