Shows how to use xtd::threading::semaphore class.
#include <xtd/threading/interlocked>
#include <xtd/threading/semaphore>
#include <xtd/threading/thread>
#include <xtd/console>
#include <xtd/startup>
namespace mutex_example {
class program {
public:
static void main() {
for(
auto i = 1;
i <= 5; ++
i) {
threads.emplace_back(worker);
}
pool.release(3);
}
"and waits for the semaphore.", num);
pool.wait_one();
num, pool.release());
}
private:
inline static std::vector<thread> threads = std::vector<thread>(5);
};
}