From: Martin Quinson Date: Sun, 27 Feb 2022 09:21:45 +0000 (+0100) Subject: cosmetics (sg4 namespace, comments, log channel) X-Git-Tag: v3.31~305 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5d0ee745165abb321ef9b2c494b6490cbe7922aa cosmetics (sg4 namespace, comments, log channel) --- diff --git a/examples/cpp/synchro-semaphore/s4u-synchro-semaphore.cpp b/examples/cpp/synchro-semaphore/s4u-synchro-semaphore.cpp index 8f7e2536cd..0e708deac4 100644 --- a/examples/cpp/synchro-semaphore/s4u-synchro-semaphore.cpp +++ b/examples/cpp/synchro-semaphore/s4u-synchro-semaphore.cpp @@ -10,11 +10,13 @@ #include -XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category"); +namespace sg4 = simgrid::s4u; -const char* buffer; /* Where the data is exchanged */ -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 */ +XBT_LOG_NEW_DEFAULT_CATEGORY(sem_test, "Simple test of the semaphore"); + +const char* buffer; /* Where the data is exchanged */ +sg4::SemaphorePtr sem_empty = sg4::Semaphore::create(1); /* indicates whether the buffer is empty */ +sg4::SemaphorePtr sem_full = sg4::Semaphore::create(0); /* indicates whether the buffer is full */ static void producer(const std::vector& args) { @@ -43,10 +45,10 @@ static void consumer() int main(int argc, char **argv) { std::vector args({"one", "two", "three", ""}); - simgrid::s4u::Engine e(&argc, argv); - e.load_platform("../../platforms/two_hosts.xml"); - simgrid::s4u::Actor::create("producer", e.host_by_name("Tremblay"), producer, std::cref(args)); - simgrid::s4u::Actor::create("consumer", e.host_by_name("Jupiter"), consumer); + sg4::Engine e(&argc, argv); + e.load_platform(argc > 1 ? argv[1] : "../../platforms/two_hosts.xml"); + sg4::Actor::create("producer", e.host_by_name("Tremblay"), producer, std::cref(args)); + sg4::Actor::create("consumer", e.host_by_name("Jupiter"), consumer); e.run(); return 0; diff --git a/examples/cpp/synchro-semaphore/s4u-synchro-semaphore.tesh b/examples/cpp/synchro-semaphore/s4u-synchro-semaphore.tesh index ea805b1e4c..53636422c6 100644 --- a/examples/cpp/synchro-semaphore/s4u-synchro-semaphore.tesh +++ b/examples/cpp/synchro-semaphore/s4u-synchro-semaphore.tesh @@ -1,13 +1,13 @@ #!/usr/bin/env tesh $ ${bindir:=.}/s4u-synchro-semaphore -> [Tremblay:producer:(1) 0.000000] [s4u_test/INFO] Pushing 'one' -> [Jupiter:consumer:(2) 0.000000] [s4u_test/INFO] Receiving 'one' -> [Tremblay:producer:(1) 0.000000] [s4u_test/INFO] Pushing 'two' -> [Jupiter:consumer:(2) 0.000000] [s4u_test/INFO] Receiving 'two' -> [Tremblay:producer:(1) 0.000000] [s4u_test/INFO] Pushing 'three' -> [Jupiter:consumer:(2) 0.000000] [s4u_test/INFO] Receiving 'three' -> [Tremblay:producer:(1) 0.000000] [s4u_test/INFO] Pushing '' -> [Jupiter:consumer:(2) 0.000000] [s4u_test/INFO] Receiving '' -> [Tremblay:producer:(1) 0.000000] [s4u_test/INFO] Bye! -> [Jupiter:consumer:(2) 0.000000] [s4u_test/INFO] Bye! +> [Tremblay:producer:(1) 0.000000] [sem_test/INFO] Pushing 'one' +> [Jupiter:consumer:(2) 0.000000] [sem_test/INFO] Receiving 'one' +> [Tremblay:producer:(1) 0.000000] [sem_test/INFO] Pushing 'two' +> [Jupiter:consumer:(2) 0.000000] [sem_test/INFO] Receiving 'two' +> [Tremblay:producer:(1) 0.000000] [sem_test/INFO] Pushing 'three' +> [Jupiter:consumer:(2) 0.000000] [sem_test/INFO] Receiving 'three' +> [Tremblay:producer:(1) 0.000000] [sem_test/INFO] Pushing '' +> [Jupiter:consumer:(2) 0.000000] [sem_test/INFO] Receiving '' +> [Tremblay:producer:(1) 0.000000] [sem_test/INFO] Bye! +> [Jupiter:consumer:(2) 0.000000] [sem_test/INFO] Bye! diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index fcbf72a846..3e620e4541 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -211,7 +211,10 @@ public: /** Add a callback fired when the main simulation loop ends, just before the end of Engine::run() */ static void on_simulation_end_cb(const std::function& cb) { on_simulation_end.connect(cb); } - /** Add a callback fired when the time jumps into the future */ + /** Add a callback fired when the time jumps into the future. + * + * It is fired right after the time change (use get_clock() to get the new timestamp). + * The callback parameter is the time delta since previous timestamp. */ static void on_time_advance_cb(const std::function& cb) { on_time_advance.connect(cb); } /** Add a callback fired when the time cannot advance because of inter-actors deadlock. Note that the on_exit of each diff --git a/src/kernel/timer/Timer.cpp b/src/kernel/timer/Timer.cpp index 5cc19ee376..0038d84a01 100644 --- a/src/kernel/timer/Timer.cpp +++ b/src/kernel/timer/Timer.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2021-2022. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2021-2022. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */