1 /* Copyright (c) 2019-2022. 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>
11 namespace simgrid::xbt {
12 class XBT_PUBLIC OsSemaphore {
14 explicit inline OsSemaphore(unsigned int capa) : capa_(capa) {}
18 std::unique_lock lock(mutex_);
19 condition_.wait(lock, [this]() { return capa_ > 0; });
25 std::unique_lock lock(mutex_);
27 condition_.notify_one();
33 std::condition_variable condition_;
35 } // namespace simgrid::xbt