Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ConditionalWait.h File Reference

Go to the source code of this file.

Namespaces

namespace  Divide
 Handle console commands that start with a forward slash.
 

Macros

#define DVD_CONDITIONAL_WAIT_H_
 
#define WAIT_FOR_CONDITION_2_ARGS(condition, yld)
 
#define WAIT_FOR_CONDITION_1_ARGS(condition)   WAIT_FOR_CONDITION_2_ARGS(condition, true)
 
#define ___DETAIL_WAIT_FOR_CONDITION(...)   EXP(GET_3RD_ARG(__VA_ARGS__, WAIT_FOR_CONDITION_2_ARGS, WAIT_FOR_CONDITION_1_ARGS, ))
 
#define WAIT_FOR_CONDITION(...)   EXP(___DETAIL_WAIT_FOR_CONDITION(__VA_ARGS__)(__VA_ARGS__)); static_assert(true, "")
 
#define WAIT_FOR_CONDITION_TIMEOUT_3_ARGS(condition, timeoutMS, yld)
 
#define WAIT_FOR_CONDITION_TIMEOUT_2_ARGS(condition, timeoutMS)   WAIT_FOR_CONDITION_TIMEOUT_3_ARGS(condition, timeoutMS, true)
 
#define WAIT_FOR_CONDITION_TIMEOUT_1_ARGS(condition)   WAIT_FOR_CONDITION_TIMEOUT_3_ARGS(condition, 1.0, true)
 
#define ___DETAIL_WAIT_FOR_CONDITION_TIMEOUT(...)   EXP(GET_4TH_ARG(__VA_ARGS__, WAIT_FOR_CONDITION_TIMEOUT_3_ARGS, WAIT_FOR_CONDITION_TIMEOUT_2_ARGS, WAIT_FOR_CONDITION_TIMEOUT_1_ARGS, ))
 
#define WAIT_FOR_CONDITION_TIMEOUT(...)   EXP(___DETAIL_WAIT_FOR_CONDITION_TIMEOUT(__VA_ARGS__)(__VA_ARGS__)); static_assert(true, "")
 
#define WAIT_FOR_CONDITION_CALLBACK_4_ARGS(condition, cbk, param, yld)
 
#define WAIT_FOR_CONDITION_CALLBACK_3_ARGS(condition, cbk, param)   WAIT_FOR_CONDITION_CALLBACK_4_ARGS(condition, cbk, param, true)
 
#define WAIT_FOR_CONDITION_CALLBACK_2_ARGS(condition, cbk)   WAIT_FOR_CONDITION_CALLBACK_3_ARGS(condition, cbk, void, true)
 
#define WAIT_FOR_CONDITION_CALLBACK_1_ARGS(condition)   WAIT_FOR_CONDITION(condition)
 
#define ___DETAIL_WAIT_FOR_CONDITION_CALLBACK(...)   EXP(GET_4TH_ARG(__VA_ARGS__, WAIT_FOR_CONDITION_CALLBACK_3_ARGS, WAIT_FOR_CONDITION_CALLBACK_2_ARGS, WAIT_FOR_CONDITION_CALLBACK_1_ARGS, ))
 
#define WAIT_FOR_CONDITION_CALLBACK(...)   EXP(___DETAIL_WAIT_FOR_CONDITION_CALLBACK(__VA_ARGS__)(__VA_ARGS__)); static_assert(true, "")
 
#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_5_ARGS(condition, cbk, param, timeoutMS, yld)
 
#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_4_ARGS(condition, cbk, param, timeoutMS)   WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_5_ARGS(condition, cbk, param, timeoutMS, true)
 
#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_3_ARGS(condition, cbk, param)   WAIT_FOR_CONDITION_CALLBACK(condition, cbk, param)
 
#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_2_ARGS(condition, cbk)   WAIT_FOR_CONDITION_CALLBACK(condition, cbk)
 
#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_1_ARGS(condition)   WAIT_FOR_CONDITION(condition)
 
#define ___DETAIL_WAIT_FOR_CONDITION_CALLBACK_TIMEOUT(...)   EXP(GET_5TH_ARG(__VA_ARGS__, WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_4_ARGS, WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_3_ARGS, WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_2_ARGS, WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_1_ARGS, ))
 
#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT(...)   EXP(___DETAIL_WAIT_FOR_CONDITION_CALLBACK_TIMEOUT(__VA_ARGS__)(__VA_ARGS__)); static_assert(true, "")
 

Functions

void Divide::InitConditionalWait (PlatformContext &context) noexcept
 
void Divide::PlatformContextIdleCall ()
 
template<typename T , typename U >
constexpr void Divide::assert_type (const U &)
 

Macro Definition Documentation

◆ ___DETAIL_WAIT_FOR_CONDITION

#define ___DETAIL_WAIT_FOR_CONDITION (   ...)    EXP(GET_3RD_ARG(__VA_ARGS__, WAIT_FOR_CONDITION_2_ARGS, WAIT_FOR_CONDITION_1_ARGS, ))

Definition at line 64 of file ConditionalWait.h.

◆ ___DETAIL_WAIT_FOR_CONDITION_CALLBACK

#define ___DETAIL_WAIT_FOR_CONDITION_CALLBACK (   ...)    EXP(GET_4TH_ARG(__VA_ARGS__, WAIT_FOR_CONDITION_CALLBACK_3_ARGS, WAIT_FOR_CONDITION_CALLBACK_2_ARGS, WAIT_FOR_CONDITION_CALLBACK_1_ARGS, ))

Definition at line 114 of file ConditionalWait.h.

◆ ___DETAIL_WAIT_FOR_CONDITION_CALLBACK_TIMEOUT

◆ ___DETAIL_WAIT_FOR_CONDITION_TIMEOUT

#define ___DETAIL_WAIT_FOR_CONDITION_TIMEOUT (   ...)    EXP(GET_4TH_ARG(__VA_ARGS__, WAIT_FOR_CONDITION_TIMEOUT_3_ARGS, WAIT_FOR_CONDITION_TIMEOUT_2_ARGS, WAIT_FOR_CONDITION_TIMEOUT_1_ARGS, ))

Definition at line 94 of file ConditionalWait.h.

◆ DVD_CONDITIONAL_WAIT_H_

#define DVD_CONDITIONAL_WAIT_H_

Definition at line 34 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION

#define WAIT_FOR_CONDITION (   ...)    EXP(___DETAIL_WAIT_FOR_CONDITION(__VA_ARGS__)(__VA_ARGS__)); static_assert(true, "")

Definition at line 65 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_1_ARGS

#define WAIT_FOR_CONDITION_1_ARGS (   condition)    WAIT_FOR_CONDITION_2_ARGS(condition, true)

Definition at line 62 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_2_ARGS

#define WAIT_FOR_CONDITION_2_ARGS (   condition,
  yld 
)
Value:
{ \
assert_type<bool>(yld); \
\
if (yld) [[likely]] { \
while (!(condition)) { \
PlatformContextIdleCall(); \
std::this_thread::yield(); \
} \
} else { \
while(!(condition)) {} \
} \
}

Definition at line 48 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK

#define WAIT_FOR_CONDITION_CALLBACK (   ...)    EXP(___DETAIL_WAIT_FOR_CONDITION_CALLBACK(__VA_ARGS__)(__VA_ARGS__)); static_assert(true, "")

Definition at line 115 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK_1_ARGS

#define WAIT_FOR_CONDITION_CALLBACK_1_ARGS (   condition)    WAIT_FOR_CONDITION(condition)

Definition at line 112 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK_2_ARGS

#define WAIT_FOR_CONDITION_CALLBACK_2_ARGS (   condition,
  cbk 
)    WAIT_FOR_CONDITION_CALLBACK_3_ARGS(condition, cbk, void, true)

Definition at line 111 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK_3_ARGS

#define WAIT_FOR_CONDITION_CALLBACK_3_ARGS (   condition,
  cbk,
  param 
)    WAIT_FOR_CONDITION_CALLBACK_4_ARGS(condition, cbk, param, true)

Definition at line 110 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK_4_ARGS

#define WAIT_FOR_CONDITION_CALLBACK_4_ARGS (   condition,
  cbk,
  param,
  yld 
)
Value:
{ \
assert_type<bool>(yld); \
\
while (!(condition)) { \
cbk(param); \
PlatformContextIdleCall(); \
if (yld) [[likely]] { \
std::this_thread::yield(); \
} \
} \
}

Definition at line 97 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK_TIMEOUT

#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT (   ...)    EXP(___DETAIL_WAIT_FOR_CONDITION_CALLBACK_TIMEOUT(__VA_ARGS__)(__VA_ARGS__)); static_assert(true, "")

Definition at line 148 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_1_ARGS

#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_1_ARGS (   condition)    WAIT_FOR_CONDITION(condition)

Definition at line 145 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_2_ARGS

#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_2_ARGS (   condition,
  cbk 
)    WAIT_FOR_CONDITION_CALLBACK(condition, cbk)

Definition at line 144 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_3_ARGS

#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_3_ARGS (   condition,
  cbk,
  param 
)    WAIT_FOR_CONDITION_CALLBACK(condition, cbk, param)

Definition at line 143 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_4_ARGS

#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_4_ARGS (   condition,
  cbk,
  param,
  timeoutMS 
)    WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_5_ARGS(condition, cbk, param, timeoutMS, true)

Definition at line 142 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_5_ARGS

#define WAIT_FOR_CONDITION_CALLBACK_TIMEOUT_5_ARGS (   condition,
  cbk,
  param,
  timeoutMS,
  yld 
)
Value:
{ \
assert_type<bool>(yld); \
assert_type<D64>(timeoutMS); \
\
if ((timeoutMS) >= 0.0) { \
const D64 start = Time::ElapsedMilliseconds(true); \
\
while (!(condition)) { \
cbk(param); \
PlatformContextIdleCall(); \
\
if (Time::ElapsedMilliseconds(true) - start >= (timeoutMS)) { \
break; \
} \
\
if (yld) [[likely]] { \
std::this_thread::yield(); \
} \
} \
} else { \
WAIT_FOR_CONDITION_CALLBACK(condition, cbk, param, yld); \
} \
}

Definition at line 117 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_TIMEOUT

#define WAIT_FOR_CONDITION_TIMEOUT (   ...)    EXP(___DETAIL_WAIT_FOR_CONDITION_TIMEOUT(__VA_ARGS__)(__VA_ARGS__)); static_assert(true, "")

Definition at line 95 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_TIMEOUT_1_ARGS

#define WAIT_FOR_CONDITION_TIMEOUT_1_ARGS (   condition)    WAIT_FOR_CONDITION_TIMEOUT_3_ARGS(condition, 1.0, true)

Definition at line 92 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_TIMEOUT_2_ARGS

#define WAIT_FOR_CONDITION_TIMEOUT_2_ARGS (   condition,
  timeoutMS 
)    WAIT_FOR_CONDITION_TIMEOUT_3_ARGS(condition, timeoutMS, true)

Definition at line 91 of file ConditionalWait.h.

◆ WAIT_FOR_CONDITION_TIMEOUT_3_ARGS

#define WAIT_FOR_CONDITION_TIMEOUT_3_ARGS (   condition,
  timeoutMS,
  yld 
)
Value:
{ \
assert_type<bool>(yld); \
assert_type<D64>(timeoutMS); \
\
if (timeoutMS >= 0.0) { \
const D64 start = Time::App::ElapsedMilliseconds(); \
\
while (!(condition)) { \
PlatformContextIdleCall(); \
if (Time::App::ElapsedMilliseconds() - start >= timeoutMS) \
{ \
break; \
} \
\
if (yld) [[likely]] { \
std::this_thread::yield(); \
} \
} \
} else { \
WAIT_FOR_CONDITION(condition, yld); \
} \
}

Definition at line 67 of file ConditionalWait.h.