static void master()
{
/* Create the requested amount of actors pairs. Each pair has a specific mutex and cell in `result`. */
- int result[cfg_actor_count.get()];
+ std::vector<int> result(cfg_actor_count.get());
for (int i = 0; i < cfg_actor_count; i++) {
- result[i] = 0;
sg4::MutexPtr mutex = sg4::Mutex::create();
sg4::Actor::create("worker", sg4::Host::by_name("Jupiter"), workerLockGuard, mutex, std::ref(result[i]));
sg4::Actor::create("worker", sg4::Host::by_name("Tremblay"), worker, mutex, std::ref(result[i]));
.def("unlock", &Mutex::unlock, py::call_guard<py::gil_scoped_release>(), "Release the mutex")
// Allow mutexes to be automatically acquired/released with a context manager: `with mutex: ...`
.def("__enter__", [](Mutex* self){ self->lock(); }, py::call_guard<py::gil_scoped_release>())
- .def("__exit__", [](Mutex* self, py::object&, py::object&, py::object&){ self->unlock(); },
+ .def("__exit__", [](Mutex* self, const py::object&, const py::object&, const py::object&) { self->unlock(); },
py::call_guard<py::gil_scoped_release>());
/* Class Barrier */
{
return &maxpid;
}
-ActorIDTrait::ActorIDTrait(std::string name, aid_t ppid) : name_(std::move(name)), pid_(maxpid++), ppid_(ppid) {}
+ActorIDTrait::ActorIDTrait(const std::string& name, aid_t ppid) : name_(name), pid_(maxpid++), ppid_(ppid) {}
ActorImpl* ActorImpl::self()
{
aid_t ppid_ = -1;
public:
- explicit ActorIDTrait(std::string name, aid_t ppid);
+ explicit ActorIDTrait(const std::string& name, aid_t ppid);
const xbt::string& get_name() const { return name_; }
const char* get_cname() const { return name_.c_str(); }
aid_t get_pid() const { return pid_; }
if(event->idx>=event_list.size())
event->free_me = true;
else {
- DatedValue& nextDateVal=event_list.at(event->idx);
+ const DatedValue& nextDateVal = event_list.at(event->idx);
xbt_assert(nextDateVal.date_>=0);
xbt_assert(nextDateVal.value_>=0);
fes_->add_event(event_date +nextDateVal.date_, event);
return dateVal;
}
-Profile::Profile(const std::string& name, const std::function<ProfileBuilder::UpdateCb>& cb, double repeat_delay): name(name),cb(std::move(cb)),repeat_delay(repeat_delay) {
+Profile::Profile(const std::string& name, const std::function<ProfileBuilder::UpdateCb>& cb, double repeat_delay)
+ : name(name), cb(cb), repeat_delay(repeat_delay)
+{
xbt_assert(trace_list.find(name) == trace_list.end(), "Refusing to define trace %s twice", name.c_str());
trace_list.insert({name,this});
cb(event_list);
DatedValue next(Event* event);
const std::vector<DatedValue>& get_event_list() const { return event_list; }
- const std::string get_name() const { return name; }
+ const std::string& get_name() const { return name; }
bool is_repeating() const { return repeat_delay>=0;}
double get_repeat_delay() const { return repeat_delay;}
xbt_assert(loop_delay >= 0, "Profile loop conditions are not realizable!");
}
- double get_repeat_delay()
+ double get_repeat_delay() const
{
if (not stochastic and loop)
return loop_delay;
return -1.0;
}
- void operator()(std::vector<DatedValue>& event_list)
+ void operator()(std::vector<DatedValue>& event_list) const
{
size_t initial_size = event_list.size();
if (loop or not initial_size) {
- for (auto dv : pattern)
+ for (auto const& dv : pattern)
event_list.emplace_back(dv.get_datedvalue());
if (initial_size)
event_list.at(initial_size).date_ += loop_delay;
raise Exception(f"No test found in {filename}. Please fix it.")
return res
-def categorize(tool, toolname, test_ID, expected):
- outcome = tool.parse(test_ID)
+def categorize(tool, toolname, test_id, expected):
+ outcome = tool.parse(test_id)
- if not os.path.exists(f'{test_ID}.elapsed') and not os.path.exists(f'logs/{toolname}/{test_ID}.elapsed'):
+ if not os.path.exists(f'{test_id}.elapsed') and not os.path.exists(f'logs/{toolname}/{test_id}.elapsed'):
if outcome == 'failure':
elapsed = 0
else:
- raise Exception(f"Invalid test result: {test_ID}.txt exists but not {test_ID}.elapsed")
+ raise Exception(f"Invalid test result: {test_id}.txt exists but not {test_id}.elapsed")
else:
- with open(f'{test_ID}.elapsed' if os.path.exists(f'{test_ID}.elapsed') else f'logs/{toolname}/{test_ID}.elapsed', 'r') as infile:
+ with open(f'{test_id}.elapsed' if os.path.exists(f'{test_id}.elapsed') else f'logs/{toolname}/{test_id}.elapsed', 'r') as infile:
elapsed = infile.read()
# Properly categorize this run
with open(f'{cachefile}.txt', 'w') as outfile:
outfile.write(output)
with open(f'{cachefile}.md5sum', 'w') as outfile:
- hash = hashlib.md5()
+ hashed = hashlib.md5()
with open(filename, 'rb') as sourcefile :
for chunk in iter(lambda: sourcefile.read(4096), b""):
- hash.update(chunk)
- outfile.write(hash.hexdigest())
+ hashed.update(chunk)
+ outfile.write(hashed.hexdigest())
return True