X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/43388fb03f79aae5ddd0572c0081cfbe1cf22670..ac080087b39ef79ff497d3992ff04b3e20fe40b2:/include/simgrid/s4u/ConditionVariable.hpp diff --git a/include/simgrid/s4u/ConditionVariable.hpp b/include/simgrid/s4u/ConditionVariable.hpp index 2ccf89d5e9..f11df5c7a7 100644 --- a/include/simgrid/s4u/ConditionVariable.hpp +++ b/include/simgrid/s4u/ConditionVariable.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2006-2019. 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. */ @@ -6,19 +6,12 @@ #ifndef SIMGRID_S4U_COND_VARIABLE_HPP #define SIMGRID_S4U_COND_VARIABLE_HPP -#include -#include -#include -#include -#include // std::swap - -#include - -#include +#include #include #include -#include + +#include namespace simgrid { namespace s4u { @@ -30,21 +23,20 @@ namespace s4u { * semantic. But we currently use (only) double for both durations and * timestamp timeouts. */ -XBT_PUBLIC_CLASS ConditionVariable -{ +class XBT_PUBLIC ConditionVariable { private: - friend s_smx_cond; - smx_cond_t cond_; - ConditionVariable(smx_cond_t cond) : cond_(cond) {} + friend kernel::activity::ConditionVariableImpl; + kernel::activity::ConditionVariableImpl* const cond_; + public: + explicit ConditionVariable(kernel::activity::ConditionVariableImpl* cond) : cond_(cond) {} ConditionVariable(ConditionVariable const&) = delete; ConditionVariable& operator=(ConditionVariable const&) = delete; - friend XBT_PUBLIC(void) intrusive_ptr_add_ref(ConditionVariable * cond); - friend XBT_PUBLIC(void) intrusive_ptr_release(ConditionVariable * cond); - using Ptr = boost::intrusive_ptr; + friend XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariable * cond); + friend XBT_PUBLIC void intrusive_ptr_release(ConditionVariable * cond); - static Ptr createConditionVariable(); + static ConditionVariablePtr create(); // Wait functions without time: @@ -52,7 +44,7 @@ public: void wait(std::unique_lock & lock); template void wait(std::unique_lock & lock, P pred) { - while (!pred()) + while (not pred()) wait(lock); } @@ -62,7 +54,7 @@ public: std::cv_status wait_for(std::unique_lock & lock, double duration); template bool wait_until(std::unique_lock & lock, double timeout_time, P pred) { - while (!pred()) + while (not pred()) if (this->wait_until(lock, timeout_time) == std::cv_status::timeout) return pred(); return true; @@ -103,13 +95,9 @@ public: void notify_one(); void notify_all(); - - XBT_ATTRIB_DEPRECATED("Use notify_one() instead") - void notify() { notify_one(); } }; -using ConditionVariablePtr = ConditionVariable::Ptr; -} -} // namespace simgrid::s4u +} // namespace s4u +} // namespace simgrid #endif