Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "semaphore.h"
- Semaphore::Semaphore(uint32_t count) {
- count = count;
- }
- Semaphore::~Semaphore() {
- }
- void Semaphore::wait() {
- std::unique_lock<std::mutex> lock(mtx);
- while (!count)
- cv.wait(lock);
- count--;
- }
- void Semaphore::notify() {
- std::unique_lock<std::mutex> lock(mtx);
- count++;
- cv.notify_one();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement