Proper Interrupt Handling

This commit is contained in:
loki
2020-01-20 00:22:13 +01:00
parent ad5cddd426
commit a23494b10c
7 changed files with 121 additions and 24 deletions

View File

@@ -29,6 +29,7 @@ public:
_cv.notify_all();
}
// pop and view shoud not be used interchangebly
status_t pop() {
std::unique_lock ul{_lock};
@@ -49,6 +50,25 @@ public:
return val;
}
// pop and view shoud not be used interchangebly
const status_t &view() {
std::unique_lock ul{_lock};
if (!_continue) {
return util::false_v<status_t>;
}
while (!_status) {
_cv.wait(ul);
if (!_continue) {
return util::false_v<status_t>;
}
}
return _status;
}
bool peek() {
std::lock_guard lg { _lock };