1 /* Copyright (c) 2019. 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 #include <condition_variable>
11 class XBT_PUBLIC OsSemaphore {
13 explicit inline OsSemaphore(unsigned int capa) : capa_(capa) {}
17 std::unique_lock<std::mutex> lock(mutex_);
18 condition_.wait(lock, [this]() { return capa_ > 0; });
24 std::unique_lock<std::mutex> lock(mutex_);
26 condition_.notify_one();
32 std::condition_variable condition_;
35 } // namespace simgrid