mirror of
https://github.com/browsermt/bergamot-translator.git
synced 2024-10-26 05:43:59 +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,19 +113,17 @@ class Semaphore {
|
||||
|
||||
|
||||
void wait() {
|
||||
while (true) {
|
||||
switch (WaitForSingleObject(sem_, 0L)) {
|
||||
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:
|
||||
continue;
|
||||
ABORT("Timeout on an infinite wait?");
|
||||
case WAIT_FAILED:
|
||||
ABORT("Waiting on Semaphore failed {}", GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void post() {
|
||||
ABORT_IF(!ReleaseSemaphore(sem_, 1, NULL), "Failed to release Semaphore {}", GetLastError());
|
||||
|
Loading…
Reference in New Issue
Block a user