mirror of
https://github.com/browsermt/bergamot-translator.git
synced 2024-09-11 05:35:33 +03:00
Fix busy loop in windows (#131)
* Fix busy loop in windows * Nick wants the while loop gone * Fix continue leftover Co-authored-by: Nikolay Bogoychev <nheart@gmail.com>
This commit is contained in:
parent
a63533b241
commit
c61b2bdd10
@ -113,17 +113,15 @@ class Semaphore {
|
||||
|
||||
|
||||
void wait() {
|
||||
while (true) {
|
||||
switch (WaitForSingleObject(sem_, 0L)) {
|
||||
case WAIT_OBJECT_0:
|
||||
return;
|
||||
case WAIT_ABANDONED:
|
||||
ABORT("A semaphore can't be abandoned, confused by Windows");
|
||||
case WAIT_TIMEOUT:
|
||||
continue;
|
||||
case WAIT_FAILED:
|
||||
ABORT("Waiting on Semaphore failed {}", GetLastError());
|
||||
}
|
||||
switch (WaitForSingleObject(sem_, INFINITE)) {
|
||||
case WAIT_OBJECT_0:
|
||||
return;
|
||||
case WAIT_ABANDONED:
|
||||
ABORT("A semaphore can't be abandoned, confused by Windows");
|
||||
case WAIT_TIMEOUT:
|
||||
ABORT("Timeout on an infinite wait?");
|
||||
case WAIT_FAILED:
|
||||
ABORT("Waiting on Semaphore failed {}", GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user