File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -49,21 +49,29 @@ class SlowCounter final : public Component
49
49
50
50
void Process_ ( SignalBus&, SignalBus& outputs ) override
51
51
{
52
- auto start = std::chrono::high_resolution_clock::now ();
52
+ _start = std::chrono::high_resolution_clock::now ();
53
53
54
54
outputs.SetValue ( 0 , _count++ );
55
55
56
- std::chrono::duration<double , std::micro> elapsedMs;
57
- do
56
+ if ( _waitMs <= 0 )
58
57
{
59
- std::this_thread::yield ();
60
- elapsedMs = std::chrono::high_resolution_clock::now () - start;
61
- } while ( elapsedMs.count () < _waitMs );
62
-
63
- _waitMs = 1000.0 - ( elapsedMs.count () - _waitMs );
58
+ _waitMs += 1000.0 ;
59
+ }
60
+ else
61
+ {
62
+ do
63
+ {
64
+ std::this_thread::yield ();
65
+ _elapsedMs = std::chrono::high_resolution_clock::now () - _start;
66
+ } while ( _elapsedMs.count () < _waitMs );
67
+
68
+ _waitMs = 1000.0 - ( _elapsedMs.count () - _waitMs );
69
+ }
64
70
}
65
71
66
72
private:
73
+ std::chrono::high_resolution_clock::time_point _start;
74
+ std::chrono::duration<double , std::micro> _elapsedMs;
67
75
int _count;
68
76
double _waitMs = 1000.0 ;
69
77
};
You can’t perform that action at this time.
0 commit comments