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
9 #include <utility> // std::swap
11 #include <simgrid/simix.h>
12 #include <simgrid/s4u/mutex.hpp>
19 XBT_PUBLIC_CLASS ConditionVariable {
24 ConditionVariable(ConditionVariable* cond) : cond_(SIMIX_cond_ref(cond->cond_)) {}
27 // Copy+move (with the copy-and-swap idiom):
28 ConditionVariable(ConditionVariable const& cond) : cond_(SIMIX_cond_ref(cond.cond_)) {}
29 friend void swap(ConditionVariable& first, ConditionVariable& second)
32 swap(first.cond_, second.cond_);
34 ConditionVariable& operator=(ConditionVariable cond)
39 ConditionVariable(ConditionVariable&& cond) : cond_(nullptr)
46 return cond_ != nullptr;
52 void wait(Mutex *mutex);
53 void wait_for(Mutex *mutex, double time);
65 }} // namespace simgrid::s4u
67 #endif /* SIMGRID_S4U_COND_VARIABLE_HPP */