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. */
8 #include <condition_variable>
13 class XBT_PUBLIC OsSemaphore {
15 explicit inline OsSemaphore(unsigned int capa) : capa_(capa) {}
19 std::unique_lock<std::mutex> lock(mutex_);
20 condition_.wait(lock, [this]() { return capa_ > 0; });
26 std::unique_lock<std::mutex> lock(mutex_);
28 condition_.notify_one();
34 std::condition_variable condition_;
37 } // namespace simgrid