List of commits:
Subject Hash Author Date (UTC)
rm emitter 55ae1aa2ce377d75e47d18a2ed29b44b7e24f93f mucbuc 2019-11-12 04:49:21
once while emit recursive 172a4d72599206575d18b2055e5a0231646d9274 mucbuc 2019-11-12 04:44:22
once_wile_emit 785a96521c22785401b9408a54a4ffb5c1541fa1 mucbuc 2019-11-12 04:37:40
on_while_emit 40ce61bbb69d5557944c3055d7fca492acf86e70 mucbuc 2019-11-11 15:21:30
modify while traverse ed70186f19dea7c92a9b98c0df7aec4973a37b98 mucbuc 2019-11-11 15:10:58
on test b8fc778d7056fb108fbdd7318f294e2b340faeeb mucbuc 2019-11-11 15:01:22
emit with args a40831a0902f0dfa35d8f5e314b1e5b21955eae7 mucbuc 2019-11-11 14:40:46
emit with arg 2cfab1f1668896ac6d58e868b8ee6d41a79dc447 mucbuc 2019-11-11 02:45:45
check dispatch logic 5b40033514e610292c25336b821829675c8f7edd mucbuc 2019-11-11 02:35:18
another test 718946ff7621bab0d8242e19ab423626c41a0b97 mucbuc 2019-11-11 02:20:42
emit once d3d244834caec7f581b254957c22b8f1c2af5321 mucbuc 2019-11-11 00:31:05
brreaking apart tests 0fa426d441993960bb8752d646744c748f2767f4 mucbuc 2019-11-11 00:13:05
trimmed 765e78aeba5eab8cd4ab933792327b393322c56a mucbuc 2019-11-10 22:39:52
fix convcurent test 11773096bd273e10835aa534f8f45ed2f25b2af6 mucbuc 2019-11-09 20:10:17
break appat e70933ddd90fcc006e0456cb60b096144e17b8bf mucbuc 2019-11-09 19:52:07
use paramete pack 04b380271051ac0f8a18135fde01a80b8e6b67ef mucbuc 2019-11-05 04:48:58
cleanup 69d0ce30002b97c5a2da1309677e0078b24f5615 mucbuc 2019-11-03 00:31:22
fix compile time error fbc1c35e2389d9fffebe94808385ded809b4061a mucbuc 2019-11-03 00:30:41
rm dynamo 10a004cc3ffda178fe3c592d1e32e5a39078adff mucbuc 2019-11-03 00:07:17
point to aws code commit fdfa4593d13b1fadcbed55b91b37239dfabc0941 mucbuc 2019-11-02 23:57:24
Commit 55ae1aa2ce377d75e47d18a2ed29b44b7e24f93f - rm emitter
Author: mucbuc
Author date (UTC): 2019-11-12 04:49
Committer name: mucbuc
Committer date (UTC): 2019-11-12 04:49
Parent(s): 172a4d72599206575d18b2055e5a0231646d9274
Signer:
Signing key:
Signing status: N
Tree: 27790687341f6f97d3c3a27405324be5028c0bd4
File Lines added Lines deleted
test/emitter.json 0 10
test/qemitter.json 0 10
test/src/dispatch_logic.cpp 0 1
test/src/emitter.cpp 0 14
test/src/emitter.h 0 415
test/tests.json 2 1
File test/emitter.json deleted (index 0761208..0000000)
1 {
2 "include":[
3 "lib/ohm/ohm.json"
4 ],
5 "sources": [
6 "src/emitter.cpp",
7 "src/emitter.h",
8 "src/emitter_fwd.h"
9 ]
10 }
File test/qemitter.json deleted (index 7c03425..0000000)
1 {
2 "include":[
3 "lib/ohm/ohm.json"
4 ],
5 "sources": [
6 "src/qemitter.cpp",
7 "src/emitter.h",
8 "src/emitter_fwd.h"
9 ]
10 }
File test/src/dispatch_logic.cpp changed (mode: 100644) (index c05452e..ca0b1bb)
1 1 #include <iostream> #include <iostream>
2 2 #include <vector> #include <vector>
3 3 #include <tmp/src/test.h> #include <tmp/src/test.h>
4 #include <lib/ohm/src/emitter.h>
5 4 #include <lib/ohm/src/quemitter.h> #include <lib/ohm/src/quemitter.h>
6 5
7 6 using namespace std; using namespace std;
File test/src/emitter.cpp deleted (index 155b87e..0000000)
1 #include <tmp/src/test.h>
2
3 #include <lib/ohm/src/emitter.h>
4 #include "emitter.h"
5
6 int main()
7 {
8 using namespace std;
9
10 test_emitter<om636::control::Emitter>();
11
12 return 0;
13 }
14
File test/src/emitter.h deleted (index b726fa7..0000000)
1 #include <tmp/src/test.h>
2
3 #include <iostream>
4 #include <vector>
5
6 using namespace std;
7 using namespace om636;
8 /*
9 template <template <class, class> class T>
10 void check_emit_once()
11 {
12 typedef T<string, function<void(int)> > emitter_type;
13 emitter_type e;
14
15 unsigned counter(0);
16
17 auto l(e.once("hello", [&](int) {
18 ++counter;
19 }));
20
21 auto k(e.once("allo", [&](int) {
22 ++counter;
23 }));
24
25 e.emit("hello", 0);
26 e.emit("hello", 0);
27 e.emit("allo", 9);
28 e.emit("allo", 9);
29
30 ASSERT(counter == 2);
31
32 FOOTER;
33 }
34
35 template <template <class, class> class T>
36 void check_emit_with_arg()
37 {
38 typedef T<string, function<void(int)> > emitter_type;
39 typedef typename emitter_type::listener_type listener_type;
40 emitter_type e;
41
42 unsigned test_passed(0);
43 string event("e");
44
45 listener_type p(e.once(event, [&](int i) {
46 ASSERT(i == 99);
47 ++test_passed;
48 }));
49
50 listener_type q(e.on(event, [&](int i) {
51 ASSERT(i == 99);
52 ++test_passed;
53 }));
54
55 e.emit(event, 99);
56
57 ASSERT(test_passed == 2);
58
59 FOOTER;
60 }
61
62 template <template <class, class> class T>
63 void check_emit_with_args()
64 {
65 typedef T<string, function<void(int, int)> > emitter_type;
66 typedef typename emitter_type::listener_type listener_type;
67 emitter_type e;
68
69 unsigned test_passed(0);
70 string event("e");
71
72 listener_type p(e.once(event, [&](int i, int j) {
73 ASSERT(i == 99);
74 ASSERT(j == 3);
75 ++test_passed;
76 }));
77
78 listener_type q(e.on(event, [&](int i, int j) {
79 ASSERT(i == 99);
80 ASSERT(j == 3);
81 ++test_passed;
82 }));
83
84 e.emit(event, 99, 3);
85
86 ASSERT(test_passed == 2);
87
88 FOOTER;
89 }
90
91 template <template <class, class> class T>
92 void check_emit_while_emit()
93 {
94 typedef T<string, function<void()> > emitter_type;
95 typedef typename emitter_type::listener_type listener_type;
96
97 size_t counter(0);
98
99 emitter_type e;
100 string event("e");
101 listener_type p(e.once(event, [&]() {
102 ++counter;
103 e.emit(event);
104 }));
105
106 e.emit(event);
107
108 ASSERT(counter == 1);
109
110 FOOTER;
111 }
112
113 /////////////////////////////////////////////////////////////////
114 template <template <class, class> class T>
115 void check_modify_while_traversal()
116 {
117 typedef T<string, function<void()> > emitter_type;
118 typedef typename emitter_type::listener_type listener_type;
119
120 static emitter_type emitter;
121 static unsigned trap(0);
122 static const string event("load");
123 struct tester {
124 static void trigger_trap()
125 {
126 ++trap;
127 }
128
129 static void remove()
130 {
131 ++trap;
132 emitter.removeListeners(event);
133 }
134
135 static void removeAll()
136 {
137 ++trap;
138 emitter.removeAllListeners();
139 }
140 };
141
142 vector<listener_type> listeners;
143
144 // test remove while traverse
145 listeners.push_back(emitter.on(event, tester::remove));
146 listeners.push_back(emitter.on(event, tester::remove));
147 listeners.push_back(emitter.once(event, tester::remove));
148 emitter.emit(event);
149 ASSERT(trap == 1);
150
151 // test removeAll while traverse
152 listeners.push_back(emitter.on(event, tester::removeAll));
153 listeners.push_back(emitter.on(event, tester::removeAll));
154 listeners.push_back(emitter.once(event, tester::removeAll));
155 emitter.emit(event);
156 ASSERT(trap == 2);
157
158 // test insert while traverse
159 listeners.push_back(emitter.once(event, [&]() {
160 listeners.push_back(emitter.on(event, tester::trigger_trap));
161 listeners.push_back(emitter.once(event, tester::trigger_trap));
162 }));
163 emitter.emit(event);
164 ASSERT(trap == 2);
165
166 emitter.emit(event);
167 ASSERT(trap == 4);
168
169 emitter.emit(event);
170 ASSERT(trap == 5);
171
172 FOOTER;
173 }
174 */
175 /////////////////////////////////////////////////////////////////
176 template <template <class, class> class T>
177 void check_dispatch_logic()
178 {
179 typedef T<string, function<void()> > emitter_type;
180 typedef typename emitter_type::listener_type listener_type;
181
182 static unsigned trap(0);
183 struct tester {
184 static void trigger_trap()
185 {
186 ++trap;
187 }
188 };
189
190 emitter_type emitter;
191 vector<listener_type> listeners;
192 string event("calculate answer to L.U. and E.");
193
194 trap = 0;
195
196 // check dead agent
197 emitter.once(event, tester::trigger_trap);
198 emitter.emit(event);
199 ASSERT(trap == 0);
200
201 // check once
202 listeners.push_back(emitter.once(event, tester::trigger_trap));
203 emitter.emit(event);
204 ASSERT(trap == 1);
205 emitter.emit(event);
206 ASSERT(trap == 1);
207
208 // check on
209 listeners.push_back(emitter.on(event, tester::trigger_trap));
210 emitter.emit(event);
211 ASSERT(trap == 2);
212 emitter.emit(event);
213 ASSERT(trap == 3);
214
215 // check duplicate
216 listeners.push_back(emitter.on(event, tester::trigger_trap));
217 emitter.emit(event);
218 ASSERT(trap == 5);
219
220 FOOTER;
221 }
222 /*
223 /////////////////////////////////////////////////////////////////
224 template <template <class, class> class T>
225 void check_agent_life_time()
226 {
227 struct dummy_callback {
228 dummy_callback()
229 {
230 ++instance_counter();
231 }
232
233 dummy_callback(const dummy_callback&)
234 : dummy_callback()
235 {
236 }
237
238 ~dummy_callback()
239 {
240 --instance_counter();
241 }
242
243 dummy_callback& operator=(const dummy_callback&) = default;
244
245 static size_t& instance_counter()
246 {
247 static size_t counter(0);
248 return counter;
249 }
250 };
251
252 typedef T<string, dummy_callback> emitter_type;
253 typedef typename emitter_type::listener_type listener_type;
254
255 static string event("init");
256 emitter_type emitter;
257
258 if (1) {
259 auto listener(emitter.on(event, dummy_callback()));
260 emitter.removeListeners(event);
261
262 // this reference is owned by the listener
263 ASSERT(dummy_callback::instance_counter() == 1);
264 }
265 ASSERT(!dummy_callback::instance_counter());
266
267 if (1) {
268 auto listener(emitter.on(event, dummy_callback()));
269 emitter.removeAllListeners();
270
271 // this reference is owned by the listener
272 ASSERT(dummy_callback::instance_counter() == 1);
273 }
274 ASSERT(!dummy_callback::instance_counter());
275
276 if (1) {
277 listener_type listener;
278 if (1) {
279 auto temp(emitter.on(event, dummy_callback()));
280 ASSERT(dummy_callback::instance_counter() == 1);
281
282 listener = temp;
283
284 ASSERT(dummy_callback::instance_counter() == 1);
285 }
286
287 // this reference is owned by the emitter
288 ASSERT(dummy_callback::instance_counter() == 1);
289 }
290
291 emitter.removeListeners(event);
292 ASSERT(!dummy_callback::instance_counter());
293
294 FOOTER;
295 }
296
297 template <template <class, class> class T>
298 void check_on()
299 {
300 typedef T<string, function<void()> > emitter_type;
301 typedef typename emitter_type::listener_type listener_type;
302
303 emitter_type emitter;
304 vector<listener_type> listeners;
305
306 unsigned counter(0);
307
308 listeners.push_back(emitter.on("on", [&]() {
309 ++counter;
310 }));
311
312 emitter.emit("on");
313 emitter.emit("on");
314 emitter.emit("on");
315 emitter.emit("on");
316
317 ASSERT(counter == 4);
318
319 FOOTER;
320 }
321
322 template <template <class, class> class T>
323 void check_on_while_emit()
324 {
325 typedef T<string, function<void()> > emitter_type;
326 typedef typename emitter_type::listener_type listener_type;
327
328 emitter_type emitter;
329 vector<listener_type> listeners;
330
331 unsigned counter(0);
332
333 listeners.push_back(emitter.once("load", [&]() {
334 listeners.push_back(emitter.on("on", [&]() {
335 ++counter;
336 }));
337
338 emitter.emit("on");
339 }));
340
341 emitter.emit("load");
342 emitter.emit("on");
343
344 ASSERT(counter == 2);
345
346 FOOTER;
347 }
348
349 template <template <class, class> class T>
350 void check_once_while_emit()
351 {
352 typedef T<string, function<void()> > emitter_type;
353 typedef typename emitter_type::listener_type listener_type;
354
355 emitter_type emitter;
356 vector<listener_type> listeners;
357
358 unsigned counter(0);
359
360 listeners.push_back(emitter.once("load", [&]() {
361 listeners.push_back(emitter.once("on", [&]() {
362 ++counter;
363 }));
364
365 emitter.emit("on");
366 }));
367
368 emitter.emit("load");
369 emitter.emit("on");
370
371 ASSERT(counter == 1);
372
373 FOOTER;
374 }
375
376 template <template <class, class> class T>
377 void check_once_while_emit_recursive()
378 {
379 typedef T<string, function<void()> > emitter_type;
380 typedef typename emitter_type::listener_type listener_type;
381
382 emitter_type emitter;
383 vector<listener_type> listeners;
384
385 unsigned counter(0);
386
387 listeners.push_back(emitter.once("on", [&]() {
388 ++counter;
389 emitter.emit("on");
390 }));
391
392 emitter.emit("on");
393
394 ASSERT(counter == 1);
395
396 FOOTER;
397 }
398 */
399 template <template <class, class> class T>
400 void test_emitter()
401 {
402 check_dispatch_logic<T>();/*
403 check_agent_life_time<T>();
404 check_modify_while_traversal<T>();
405 check_emit_while_emit<T>();
406 check_emit_with_args<T>();
407 check_emit_once<T>();
408 check_on<T>();
409 check_on_while_emit<T>();
410 check_once_while_emit<T>();
411 check_once_while_emit_recursive<T>();
412 */
413 FOOTER;
414 }
415
File test/tests.json changed (mode: 100644) (index 8d7b9da..87033dd)
10 10 "on.json", "on.json",
11 11 "modify_while_traversal.json", "modify_while_traversal.json",
12 12 "on_while_emit.json", "on_while_emit.json",
13 "once_while_emit.json"
13 "once_while_emit.json",
14 "once_while_emit_recursive.json"
14 15 ] } ] }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mucbuc/ohm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mucbuc/ohm

Clone this repository using git:
git clone git://git.rocketgit.com/user/mucbuc/ohm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main