5template <
typename TYPE >
6inline TYPE default_keep_value()
15inline bool default_keep_value < bool >()
23template <
typename TYPE >
35 ___keep(___keep&& keep);
37 template <
typename TYPE_KEEP,
typename TYPE_KEEP_AWAY >
38 ___keep(TYPE& kept,
const TYPE_KEEP& keepValue,
const TYPE_KEEP_AWAY& keepAwayValue,
bool bStartKept =
true);
40 template <
typename TYPE_KEEP >
41 ___keep(TYPE& kept,
const TYPE_KEEP& keepValue = ::default_keep_value < TYPE >());
52template <
typename TYPE >
53template <
typename TYPE_KEEP,
typename TYPE_KEEP_AWAY >
54___keep < TYPE >
::___keep(TYPE& kept,
const TYPE_KEEP& keepValue,
const TYPE_KEEP_AWAY& keepAwayValue,
bool bStartKept) :
55 m_keepValue(keepValue),
56 m_keepAwayValue(keepAwayValue),
73template <
typename TYPE >
74template <
typename TYPE_KEEP >
75___keep < TYPE >
::___keep(TYPE& kept,
const TYPE_KEEP& keepValue) :
76 m_keepValue(keepValue),
77 m_keepAwayValue(kept),
85template <
typename TYPE >
87 m_keepValue(keep.m_keepValue),
88 m_keepAwayValue(keep.m_keepAwayValue),
89 m_pKept(keep.m_pKept),
92 keep.m_pKept =
nullptr;
96template <
typename TYPE >
97___keep<TYPE>::~___keep()
106template <
typename TYPE >
107void ___keep<TYPE>::Keep()
111 *m_pKept = m_keepValue;
118void ___keep<TYPE>::KeepAway()
122 *m_pKept = m_keepAwayValue;
128template <
typename TYPE >
129___keep < TYPE > keep(TYPE& kept)
132 return ___keep < TYPE >(kept, ::default_keep_value < TYPE >());
137template <
typename TYPE,
typename TYPE_KEEP >
138___keep < TYPE > keep(TYPE& kept,
const TYPE_KEEP& keepValue)
141 return ___keep < TYPE >(kept, keepValue);
146template <
typename TYPE,
typename TYPE_KEEP,
typename TYPE_KEEP_AWAY >
147___keep < TYPE > keep(TYPE& kept,
const TYPE_KEEP& keepValue,
const TYPE_KEEP_AWAY& keepAwayValue,
bool bStartKept =
true)
150 return ___keep < TYPE >(kept, keepValue, keepAwayValue, bStartKept);
158#define KEEP(...) auto COUNTER_TOKEN(KEEP) = keep(__VA_ARGS__)
159#define __keep_true(...) auto COUNTER_TOKEN(__keep_true) = keep(__VA_ARGS__, true)
160#define __keep_false(...) auto COUNTER_TOKEN(__keep_false) = keep(__VA_ARGS__, false)
161#define __keep_task_payload(...) auto COUNTER_TOKEN(__keep_task_payload) = keep_task_payload(__VA_ARGS__)
162#define __keep_current_thread(...) auto COUNTER_TOKEN(__keep_current_thread) = keep(__VA_ARGS__, ::get_task())
167#define KEEP(...) auto COUNTER_TOKEN(KEEP) = keep(__VA_ARGS__)
168#define __keep_true(...) auto COUNTER_TOKEN(__keep_true) = keep(__VA_ARGS__, true)
169#define __keep_false(...) auto COUNTER_TOKEN(__keep_false) = keep(__VA_ARGS__, false)
170#define __keep_task_payload(...) auto COUNTER_TOKEN(__keep_task_payload) = keep_task_payload(__VA_ARGS__)
171#define __keep_current_thread(...) auto COUNTER_TOKEN(__keep_current_thread) = keep(__VA_ARGS__, ::get_task())
174#define __task_guard_ret(flag, ret) \
176synchronous_lock synchronouslock(this->synchronization()); \
185auto COUNTER_TOKEN(__task_guard_task_ret) = keep(flag); \
187synchronouslock.unlock()
189#define __task_guard(flag) __task_guard_ret(flag, return)
192#define __guard_wait_ret(flag, ret) \
194synchronous_lock synchronouslock(this->synchronization()); \
200 synchronouslock.unlock(); \
202 if (!task_sleep(100_ms)) \
209 synchronouslock.lock(); \
214auto COUNTER_TOKEN(__guard_wait_ret) = keep(&flag); \
216synchronouslock.unlock()
218#define __guard_wait(flag) __task_guard_ret(flag, return)
233 template <
typename TYPE_KEEP>
234 ___keep_on(TYPE* pKept, TYPE_KEEP keep,
bool bStartKept =
true);
235 ___keep_on(___keep_on&& on) :
236 m_keepValue(on.m_keepValue),
237 m_bWasSet(on.m_bWasSet),
241 on.m_pKept =
nullptr;
243 virtual ~___keep_on();
253template <
typename TYPE >
254template <
typename TYPE_KEEP >
255___keep_on<TYPE>::___keep_on(TYPE* pKept, TYPE_KEEP keepValue,
bool bStartKept) :
256 m_keepValue(keepValue),
272___keep_on<TYPE>::~___keep_on()
281void ___keep_on<TYPE>::Keep()
285 *m_pKept |= m_keepValue;
291void ___keep_on<TYPE>::KeepAway()
293 if (m_pKept && !m_bWasSet)
295 *m_pKept &= ~m_keepValue;
301template <
typename TYPE,
typename TYPE_KEEP >
302___keep_on < TYPE > keep_on(TYPE& kept, TYPE_KEEP keepValue,
bool bStartKept =
true)
305 return ___keep_on < TYPE >(&kept, keepValue, bStartKept);
310template <
typename TYPE,
typename TYPE_KEEP >
311___keep_on < TYPE > keep_on(TYPE* pKept, TYPE_KEEP keepValue,
bool bStartKept =
true)
314 return ___keep_on < TYPE >(pKept, keepValue, bStartKept);
318#define __keep_on(...) auto COUNTER_TOKEN(__keep_on) = keep_on(__VA_ARGS__)
322template <
typename FLAG >
328 enumeration < FLAG >& m_eflagVariable;
329 enumeration < FLAG > m_eflag;
332 ___keep_flag_on(enumeration < FLAG >& eflagVariable, FLAG iFlag) :
333 m_eflagVariable(eflagVariable),
337 m_eflagVariable |= m_eflag;
341 ___keep_flag_on(
const ___keep_flag_on& on) :
342 m_eflagVariable(on.m_eflagVariable),
352 m_eflagVariable -= m_eflag;
323class ___keep_flag_on {
…};
359template <
typename FLAG >
360inline ___keep_flag_on < FLAG > keep_flag_on(enumeration < FLAG >& eflagVariable, FLAG eflag)
363 return ___keep_flag_on < FLAG >(eflagVariable, eflag);
368#define __keep_flag_on(...) auto COUNTER_TOKEN(__keep_flag_on) = keep_flag_on(__VA_ARGS__)
372#define KEEP(...) auto COUNTER_TOKEN(KEEP) = keep(__VA_ARGS__)
373#define __keep_true(...) auto COUNTER_TOKEN(__keep_true) = keep(__VA_ARGS__, true)
374#define __keep_false(...) auto COUNTER_TOKEN(__keep_false) = keep(__VA_ARGS__, false)
375#define __keep_task_flag(...) auto COUNTER_TOKEN(__keep_task_flag) = keep_task_flag(__VA_ARGS__)
376#define __keep_current_thread(...) auto COUNTER_TOKEN(__keep_current_thread) = keep(__VA_ARGS__, ::get_task())
379#define __task_guard_ret(flag, ret) \
381synchronous_lock synchronouslock(this->synchronization()); \
390auto COUNTER_TOKEN(__task_guard_task_ret) = keep(flag); \
392synchronouslock.unlock()
394#define __task_guard(flag) __task_guard_ret(flag, return)
397#define __guard_wait_ret(flag, ret) \
399synchronous_lock synchronouslock(this->synchronization()); \
405 synchronouslock.unlock(); \
407 if (!task_sleep(100_ms)) \
414 synchronouslock.lock(); \
419auto COUNTER_TOKEN(__guard_wait_ret) = keep(&flag); \
421synchronouslock.unlock()
423#define __guard_wait(flag) __task_guard_ret(flag, return)
795#define __keep_current_thread(...) auto COUNTER_TOKEN(__keep_current_thread) = keep(__VA_ARGS__, ::get_task())
798#define __task_guard_ret(flag, ret) \
800synchronous_lock synchronouslock(this->synchronization()); \
809auto COUNTER_TOKEN(__task_guard_task_ret) = keep(flag); \
811synchronouslock.unlock()
813#define __task_guard(flag) __task_guard_ret(flag, return)
816#define __guard_wait_ret(flag, ret) \
818synchronous_lock synchronouslock(this->synchronization()); \
824 synchronouslock.unlock(); \
826 if (!task_sleep(100_ms)) \
833 synchronouslock.lock(); \
838auto COUNTER_TOKEN(__guard_wait_ret) = keep(&flag); \
840synchronouslock.unlock()
842#define __guard_wait(flag) __task_guard_ret(flag, return)
850#define __task_guard_ret(flag, ret) \
852synchronous_lock synchronouslock(this->synchronization()); \
861auto COUNTER_TOKEN(__task_guard_task_ret) = keep(flag); \
863synchronouslock.unlock()
865#define __task_guard(flag) __task_guard_ret(flag, return)
868#define __guard_wait_ret(flag, ret) \
870synchronous_lock synchronouslock(this->synchronization()); \
876 synchronouslock.unlock(); \
878 if (!task_sleep(100_ms)) \
885 synchronouslock.lock(); \
890auto COUNTER_TOKEN(__guard_wait_ret) = keep(&flag); \
892synchronouslock.unlock()
894#define __guard_wait(flag) __task_guard_ret(flag, return)
898#define KEEP(...) auto COUNTER_TOKEN(KEEP) = keep(__VA_ARGS__)
899#define KEEP_TRUE(...) auto COUNTER_TOKEN(__keep_true) = keep(__VA_ARGS__, true)
900#define KEEP_FALSE(...) auto COUNTER_TOKEN(__keep_false) = keep(__VA_ARGS__, false)
901#define KEEP_CURRENT_THREAD(...) auto COUNTER_TOKEN(__keep_current_thread) = keep(__VA_ARGS__, ::get_task())
904#define __task_guard_ret(flag, ret) \
906synchronous_lock synchronouslock(this->synchronization()); \
915auto COUNTER_TOKEN(__task_guard_task_ret) = keep(flag); \
917synchronouslock.unlock()
919#define __task_guard(flag) __task_guard_ret(flag, return)
922#define __guard_wait_ret(flag, ret) \
924synchronous_lock synchronouslock(this->synchronization()); \
930 synchronouslock.unlock(); \
932 if (!task_sleep(100_ms)) \
939 synchronouslock.lock(); \
944auto COUNTER_TOKEN(__guard_wait_ret) = keep(&flag); \
946synchronouslock.unlock()
948#define __guard_wait(flag) __task_guard_ret(flag, return)
951#define __keep_current_thread(...) auto COUNTER_TOKEN(__keep_current_thread) = keep(__VA_ARGS__, ::get_task())
954#define __guard_wait_ret(flag, ret) \
956synchronous_lock synchronouslock(this->synchronization()); \
962 synchronouslock.unlock(); \
964 if (!task_sleep(100_ms)) \
971 synchronouslock.lock(); \
976auto COUNTER_TOKEN(__guard_wait_ret) = keep(&flag); \
978synchronouslock.unlock()
980#define __guard_wait(flag) __task_guard_ret(flag, return)