X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0746edb369906f57c331d9336bf85ae91094ad51..0bfafcab47ae9cd7856bd8d129404c33079d6afe:/examples/s4u/synchro-condition-variable-waituntil/s4u-synchro-condition-variable-waituntil.cpp diff --git a/examples/s4u/synchro-condition-variable-waituntil/s4u-synchro-condition-variable-waituntil.cpp b/examples/s4u/synchro-condition-variable-waituntil/s4u-synchro-condition-variable-waituntil.cpp deleted file mode 100644 index edfc7e4aad..0000000000 --- a/examples/s4u/synchro-condition-variable-waituntil/s4u-synchro-condition-variable-waituntil.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (c) 2006-2021. 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. */ - -#include /* std::mutex and std::lock_guard */ -#include /* All of S4U */ - -XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category"); - -simgrid::s4u::MutexPtr mtx = nullptr; -simgrid::s4u::ConditionVariablePtr cv = nullptr; -bool ready = false; - -static void competitor(int id) -{ - XBT_INFO("Entering the race..."); - std::unique_lock lck(*mtx); - while (!ready) { - auto now = simgrid::s4u::Engine::get_clock(); - if (cv->wait_until(lck, now + (id+1)*0.25) == std::cv_status::timeout) { - XBT_INFO("Out of wait_until (timeout)"); - } - else { - XBT_INFO("Out of wait_until (YAY!)"); - } - } - XBT_INFO("Running!"); -} - -static void go() -{ - XBT_INFO("Are you ready? ..."); - simgrid::s4u::this_actor::sleep_for(3); - std::unique_lock lck(*mtx); - XBT_INFO("Go go go!"); - ready = true; - cv->notify_all(); -} - -static void main_actor() -{ - mtx = simgrid::s4u::Mutex::create(); - cv = simgrid::s4u::ConditionVariable::create(); - - auto host = simgrid::s4u::this_actor::get_host(); - for (int i = 0; i < 10; ++i) - simgrid::s4u::Actor::create("competitor", host, competitor, i); - simgrid::s4u::Actor::create("go", host, go); -} - -int main(int argc, char* argv[]) -{ - simgrid::s4u::Engine e(&argc, argv); - e.load_platform("../../platforms/small_platform.xml"); - - auto host = simgrid::s4u::Host::by_name("Tremblay"); - simgrid::s4u::Actor::create("main", host, main_actor); - - e.run(); - return 0; -}