Extend semaphore with try_wait()

This commit is contained in:
Avi Kivity
2014-08-27 17:21:12 +03:00
parent 1cfa018243
commit 85e3645866

View File

@@ -394,6 +394,15 @@ public:
_wait_list.pop_front();
}
}
bool try_wait(size_t nr = 1) {
if (_count >= nr && _wait_list.empty()) {
_count -= nr;
return true;
} else {
return false;
}
}
size_t current() const { return _count; }
};
class pollable_fd_state {