Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
Timeout.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#include <condition_variable>
5
7
9
10 //redeclare to avoid having to #include Thread.h
11 namespace Thread {
13 }
14
15 /*
16 ********************************************************************************
17 ******************* Execution::ThrowTimeoutExceptionAfter **********************
18 ********************************************************************************
19 */
20 template <typename EXCEPTION>
21 inline void ThrowTimeoutExceptionAfter (Time::TimePointSeconds afterTickCount, EXCEPTION&& exception2Throw)
22 {
23 // note the == part important, so the case of TimeoutSeconds == 0s works as 'no blocking'
24 if (Time::GetTickCount () >= afterTickCount) [[unlikely]] {
25 Throw (forward<EXCEPTION> (exception2Throw));
26 }
28 }
29 inline void ThrowTimeoutExceptionAfter (Time::TimePointSeconds afterTickCount)
30 {
31 // note the == part important, so the case of TimeoutSeconds == 0s works as 'no blocking'
32 if (Time::GetTickCount () >= afterTickCount) [[unlikely]] {
33 ThrowError (errc::timed_out);
34 }
36 }
37
38 /*
39 ********************************************************************************
40 ************************* Execution::ThrowIfTimeout ****************************
41 ********************************************************************************
42 */
43 template <typename EXCEPTION>
44 inline void ThrowIfTimeout (cv_status conditionVariableStatus, EXCEPTION&& exception2Throw)
45 {
46 if (conditionVariableStatus == cv_status::timeout) {
47 Throw (forward<EXCEPTION> (exception2Throw));
48 }
49 }
50 inline void ThrowIfTimeout (cv_status conditionVariableStatus)
51 {
52 if (conditionVariableStatus == cv_status::timeout) {
53 ThrowError (errc::timed_out);
54 }
55 }
56
57}
time_point< RealtimeClock, DurationSeconds > TimePointSeconds
TimePointSeconds is a simpler approach to chrono::time_point, which doesn't require using templates e...
Definition Realtime.h:82
void ThrowTimeoutExceptionAfter(Time::TimePointSeconds afterTickCount, EXCEPTION &&exception2Throw)
How Stroika reports a timeout.
Definition Timeout.inl:21
void ThrowIfTimeout(cv_status conditionVariableStatus, EXCEPTION &&exception2Throw)
Throw a timeout (.
Definition Timeout.inl:44
void Throw(T &&e2Throw)
like the builtin C++ 'throw', but stamps in the current Activity context and does helpful,...
Definition Throw.inl:54
void ThrowError(error_code ec)
throw a SystemErrorException with the given error_code - or std::bad_alloc for errc::not_enough_memor...