acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
retry.h
1#pragma once
2
3
4template < typename PREDICATE >
5bool predicate_retry(const class time & timeStep, const class time & timeTotal, PREDICATE predicate)
6{
7
8 auto start = time::now();
9
10 while (true)
11 {
12
13 try
14 {
15
16 //if (predicate())
17
18 predicate();
19 //{
20
21 // return true;
22
23 //}
24
25 }
26 catch (...)
27 {
28
29 return false;
30
31 }
32
33 ::preempt(timeStep);
34
35 if (start.elapsed() > timeTotal)
36 {
37
38 return false;
39
40 }
41
42 }
43
44}
45
46
47class CLASS_DECL_ACME retry
48{
49public:
50
51
52 class ::time m_timeRetry;
53
54 class ::time m_timeTimeout;
55
56
57 retry(const class ::time & timeRetry, const class ::time& timeTimeout) :
58 m_timeRetry(timeRetry),
59 m_timeTimeout(timeTimeout)
60 {
61
62 };
63
64 ~retry()
65 {
66
67
68 }
69
70 template < typename PRED >
71 bool operator()(PRED pred)
72 {
73
74 return ::predicate_retry(m_timeRetry, m_timeTimeout, pred);
75
76 }
77
78};
79
80
81
82
Definition aaa_time.h:13