aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zencore/thread.cpp')
-rw-r--r--src/zencore/thread.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/zencore/thread.cpp b/src/zencore/thread.cpp
index a55bc5d69..6092895b0 100644
--- a/src/zencore/thread.cpp
+++ b/src/zencore/thread.cpp
@@ -411,9 +411,10 @@ NamedEvent::Wait(int TimeoutMs)
}
# if defined(_GNU_SOURCE)
+ const int TimeoutSec = TimeoutMs / 1000;
struct timespec TimeoutValue = {
- .tv_sec = TimeoutMs >> 10,
- .tv_nsec = (TimeoutMs & 0x3ff) << 20,
+ .tv_sec = TimeoutSec,
+ .tv_nsec = (TimeoutMs - (TimeoutSec * 1000)) * 1000000,
};
Result = semtimedop(Sem, &SemOp, 1, &TimeoutValue);
# else
@@ -431,7 +432,6 @@ NamedEvent::Wait(int TimeoutMs)
TimeoutMs -= SleepTimeMs;
} while (TimeoutMs > 0);
# endif // _GNU_SOURCE
-
return Result == 0;
#endif
}
@@ -1225,19 +1225,20 @@ TEST_CASE("NamedEvent")
CHECK(!bEventSet);
}
+ NamedEvent ReadyEvent(Name + "_ready");
+
// Thread check
std::thread Waiter = std::thread([Name]() {
NamedEvent ReadyEvent(Name + "_ready");
ReadyEvent.Set();
NamedEvent TestEvent(Name);
- TestEvent.Wait(100);
+ TestEvent.Wait(1000);
});
- NamedEvent ReadyEvent(Name + "_ready");
ReadyEvent.Wait();
- zen::Sleep(50);
+ zen::Sleep(100);
TestEvent.Set();
Waiter.join();