1 /* Copyright (c) 2006-2016. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_S4U_COND_VARIABLE_HPP
7 #define SIMGRID_S4U_COND_VARIABLE_HPP
10 #include <utility> // std::swap
12 #include <simgrid/simix.h>
13 #include <simgrid/s4u/mutex.hpp>
20 XBT_PUBLIC_CLASS ConditionVariable {
25 ConditionVariable(ConditionVariable* cond) : cond_(SIMIX_cond_ref(cond->cond_)) {}
28 // Copy+move (with the copy-and-swap idiom):
29 ConditionVariable(ConditionVariable const& cond) : cond_(SIMIX_cond_ref(cond.cond_)) {}
30 friend void swap(ConditionVariable& first, ConditionVariable& second)
33 swap(first.cond_, second.cond_);
35 ConditionVariable& operator=(ConditionVariable cond)
40 ConditionVariable(ConditionVariable&& cond) : cond_(nullptr)
47 return cond_ != nullptr;
53 void wait(std::unique_lock<Mutex>& lock);
54 void wait_for(std::unique_lock<Mutex>& lock, double time);
66 }} // namespace simgrid::s4u
68 #endif /* SIMGRID_S4U_COND_VARIABLE_HPP */