#include <mutex>
#include <condition_variable>
using namespace std; class semaphore{
private:
mutex mtx;
condition_variable cv;
int count; public:
semaphore(int count_ = ):count(count_){;}
void notify()
{
unique_lock<mutex> lck(mtx);
++count;
cv.notify_one();
}
void wait()
{
unique_lock<mutex> lck(mtx); while(count == ){
cv.wait(lck);
}
count--;
}
};