@@ -40,81 +40,104 @@ Delegate<bool(int), Foo*> f10;
40
40
Delegate<bool (int ), Foo*> f11;
41
41
Delegate<bool (int ), Foo*> f12;
42
42
43
- void set_f0 (Fp0 _f, Foo* _o) { f0 = _f; o0 = _o; }
44
- void set_f1 (Fp0 _f, Foo* _o) { f1 = _f; o1 = _o; }
45
- void set_f2 (Fp2 _f) { f2 = { _f }; }
46
- void set_f3 (Fp2 _f) { f3 = { _f }; }
43
+ void set_f0 (Fp0 _f, Foo* _o) {
44
+ f0 = _f;
45
+ o0 = _o;
46
+ }
47
+ void set_f1 (Fp0 _f, Foo* _o) {
48
+ f1 = _f;
49
+ o1 = _o;
50
+ }
51
+ void set_f2 (Fp2 _f) {
52
+ f2 = { _f };
53
+ }
54
+ void set_f3 (Fp2 _f) {
55
+ f3 = { _f };
56
+ }
47
57
48
- void set_f4 (const std::function<bool (int )>& _f) { f4 = _f; }
49
- void set_f5 (const std::function<bool (int )>& _f) { f5 = _f; }
58
+ void set_f4 (const std::function<bool (int )>& _f) {
59
+ f4 = _f;
60
+ }
61
+ void set_f5 (const std::function<bool (int )>& _f) {
62
+ f5 = _f;
63
+ }
50
64
51
- void set_f6 (const Delegate<bool (int )>& _f) { f6 = _f; }
52
- void set_f7 (const Delegate<bool (int )>& _f) { f7 = _f; }
65
+ void set_f6 (const Delegate<bool (int )>& _f) {
66
+ f6 = _f;
67
+ }
68
+ void set_f7 (const Delegate<bool (int )>& _f) {
69
+ f7 = _f;
70
+ }
53
71
54
- void set_f8 (const Delegate<bool (int )>& _f) { f8 = _f; }
72
+ void set_f8 (const Delegate<bool (int )>& _f) {
73
+ f8 = _f;
74
+ }
55
75
56
- void set_f9 (const Delegate<bool (int ), Foo*>& _f) { f9 = _f; }
57
- void set_f10 (const Delegate<bool (int ), Foo*>& _f) { f10 = _f; }
76
+ void set_f9 (const Delegate<bool (int ), Foo*>& _f) {
77
+ f9 = _f;
78
+ }
79
+ void set_f10 (const Delegate<bool (int ), Foo*>& _f) {
80
+ f10 = _f;
81
+ }
58
82
59
- void set_f11 (const Delegate<bool (int ), Foo*>& _f) { f11 = _f; }
60
- void set_f12 (const Delegate<bool (int ), Foo*>& _f) { f12 = _f; }
83
+ void set_f11 (const Delegate<bool (int ), Foo*>& _f) {
84
+ f11 = _f;
85
+ }
86
+ void set_f12 (const Delegate<bool (int ), Foo*>& _f) {
87
+ f12 = _f;
88
+ }
10000
61
89
62
90
extern void testPrep ();
63
91
64
- void stopWatch ()
65
- {
66
- if (MAXCNT == cnt)
67
- {
68
- Serial.print (LATENCY);
69
- Serial.println (cycles / MAXCNT);
70
- cycles = 0 ;
71
- cnt = 0 ;
72
- }
92
+ void stopWatch () {
93
+ if (MAXCNT == cnt) {
94
+ Serial.print (LATENCY);
95
+ Serial.println (cycles / MAXCNT);
96
+ cycles = 0 ;
97
+ cnt = 0 ;
98
+ }
73
99
}
74
100
75
- void setup ()
76
- {
77
- Serial.begin (115200 );
78
- testPrep ();
101
+ void setup () {
102
+ Serial.begin (115200 );
103
+ testPrep ();
79
104
80
- cycles = 0 ;
81
- cnt = 0 ;
105
+ cycles = 0 ;
106
+ cnt = 0 ;
82
107
}
83
108
84
109
// Add the main program code into the continuous loop() function
85
- void loop ()
86
- {
87
- for (auto tc : testCases) {
88
- Serial.print (TESTCASE);
89
- Serial.print (tc);
90
- Serial.print (" : " );
91
- for (unsigned i = 0 ; i < MAXCNT; ++i)
92
- {
93
- auto start = ESP.getCycleCount ();
94
- switch (tc) {
95
- case F0: f0 (o0, 42 ); break ;
96
- case F1: f1 (o1, 42 ); break ;
97
- case F2: f2 (42 ); break ; // { cbCPtr }
98
- case F3: f3 (42 ); break ; // { cbCPtr }
99
-
100
- case F4: f4 (42 ); break ; // [o](int result) -> bool { return o->cb(result); }
101
- case F5: f5 (42 ); break ; // std::bind(Foo::cbwObj, o, std::placeholders::_1)
102
-
103
- case F6: f6 (42 ); break ; // [o](int result) -> bool { return o->cb(result); } <==== antipattern for Delegate, use f11 instead
104
- case F7: f7 (42 ); break ; // std::bind(Foo::cbwObj, o, std::placeholders::_1) <==== antipattern for Delegate, use f11 instead
105
-
106
- case F8: f8 (42 ); break ; // [](int result) -> bool { return cbCPtr(result); }
107
-
108
- case F9: f9 (42 ); break ; // [o](int result) -> bool { return o->cb(result); } <==== antipattern for Delegate, use f11 instead
109
- case F10: f10 (42 ); break ; // std::bind(Foo::cbwObj, o, std::placeholders::_1) <==== antipattern for Delegate, use f11 instead
110
-
111
- case F11: f11 (42 ); break ; // [](Foo* o, int result) -> bool { return o->cb(result); }, o.get() })
112
- case F12: f12 (42 ); break ; // { Foo::cbwObj, o.get() }
113
- }
114
- cycles += (ESP.getCycleCount () - start);
115
- stopWatch ();
116
- }
117
- yield ();
110
+ void loop () {
111
+ for (auto tc : testCases) {
112
+ Serial.print (TESTCASE);
113
+ Serial.print (tc);
114
+ Serial.print (" : " );
115
+ for (unsigned i = 0 ; i < MAXCNT; ++i) {
116
+ auto start = ESP.getCycleCount ();
117
+ switch (tc) {
118
+ case F0: f0 (o0, 42 ); break ;
119
+ case F1: f1 (o1, 42 ); break ;
120
+ case F2: f2 (42 ); break ; // { cbCPtr }
121
+ case F3: f3 (42 ); break ; // { cbCPtr }
122
+
123
+ case F4: f4 (42 ); break ; // [o](int result) -> bool { return o->cb(result); }
124
+ case F5: f5 (42 ); break ; // std::bind(Foo::cbwObj, o, std::placeholders::_1)
125
+
126
+ case F6: f6 (42 ); break ; // [o](int result) -> bool { return o->cb(result); } <==== antipattern for Delegate, use f11 instead
127
+ case F7: f7 (42 ); break ; // std::bind(Foo::cbwObj, o, std::placeholders::_1) <==== antipattern for Delegate, use f11 instead
128
+
129
+ case F8: f8 (42 ); break ; // [](int result) -> bool { return cbCPtr(result); }
130
+
131
+ case F9: f9 (42 ); break ; // [o](int result) -> bool { return o->cb(result); } <==== antipattern for Delegate, use f11 instead
132
+ case F10: f10 (42 ); break ; // std::bind(Foo::cbwObj, o, std::placeholders::_1) <==== antipattern for Delegate, use f11 instead
133
+
134
+ case F11: f11 (42 ); break ; // [](Foo* o, int result) -> bool { return o->cb(result); }, o.get() })
135
+ case F12: f12 (42 ); break ; // { Foo::cbwObj, o.get() }
136
+ }
137
+ cycles += (ESP.getCycleCount () - start);
138
+ stopWatch ();
118
139
}
119
- delay (16000 );
140
+ yield ();
141
+ }
142
+ delay (16000 );
120
143
}
0 commit comments