Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Two more s/pointer/reference/ for std::vector parameter.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 22 Jun 2021 21:50:16 +0000 (23:50 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 23 Jun 2021 09:14:47 +0000 (11:14 +0200)
examples/cpp/synchro-semaphore/s4u-synchro-semaphore.cpp
examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp

index d6da005..7acc1ac 100644 (file)
@@ -16,9 +16,9 @@ const char* buffer;                                                        /* Wh
 simgrid::s4u::SemaphorePtr sem_empty = simgrid::s4u::Semaphore::create(1); /* indicates whether the buffer is empty */
 simgrid::s4u::SemaphorePtr sem_full  = simgrid::s4u::Semaphore::create(0); /* indicates whether the buffer is full */
 
-static void producer(const std::vector<std::string>* args)
+static void producer(const std::vector<std::string>& args)
 {
-  for (auto const& str : *args) {
+  for (auto const& str : args) {
     sem_empty->acquire();
     XBT_INFO("Pushing '%s'", str.c_str());
     buffer = str.c_str();
@@ -45,7 +45,7 @@ int main(int argc, char **argv)
   std::vector<std::string> args({"one", "two", "three", ""});
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform("../../platforms/two_hosts.xml");
-  simgrid::s4u::Actor::create("producer", simgrid::s4u::Host::by_name("Tremblay"), producer, &args);
+  simgrid::s4u::Actor::create("producer", simgrid::s4u::Host::by_name("Tremblay"), producer, std::cref(args));
   simgrid::s4u::Actor::create("consumer", simgrid::s4u::Host::by_name("Jupiter"), consumer);
   e.run();
 
index c72bb9d..ec92ca2 100644 (file)
@@ -96,9 +96,9 @@ static int job_executor_process(Job* job)
 }
 
 // Executes a workload of SMPI processes
-static int workload_executor_process(const std::vector<std::unique_ptr<Job>>* workload)
+static int workload_executor_process(const std::vector<std::unique_ptr<Job>>& workload)
 {
-  for (auto const& job : *workload) {
+  for (auto const& job : workload) {
     // Let's wait until the job's waiting time if needed
     double curr_time = simgrid::s4u::Engine::get_clock();
     if (job->starting_time > curr_time) {
@@ -236,7 +236,7 @@ int main(int argc, char* argv[])
   }
 
   // Let's execute the workload
-  simgrid::s4u::Actor::create("workload", hosts[0], workload_executor_process, &jobs);
+  simgrid::s4u::Actor::create("workload", hosts[0], workload_executor_process, std::cref(jobs));
 
   e.run();
   XBT_INFO("Simulation finished! Final time: %g", simgrid::s4u::Engine::get_clock());