-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlistener.cpp
78 lines (61 loc) · 1.99 KB
/
listener.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include "listener.hpp"
#include "event.hpp"
#include "eventbus.hpp"
#include "publisher.hpp"
extern EventBus bus;
// Tests scenarios runned as threads
void Foo::RunTestAsyn() {
std::cout << "FooRunningFoo" << std::endl;
Publisher pub(principal);
std::cout << "after FooRunningFoo" << std::endl;
EventA *event = new EventA(5);
EventA *event2 = new EventA(10);
//const EventB eventb("Hello world");
/*Send a subscribe to the bus*/
bus.subscribe<EventA>(this);
pub.Publish<EventA>(*event);
pub.Publish<EventA>(*event2);
std::cout<<"notified"<<std::endl;
}
void Foo::RunTestSyn() {
std::cout << "FooRunningFoo" << std::endl;
Publisher pub(synch);
std::cout << "after FooRunningFoo" << std::endl;
EventA *event = new EventA(5);
EventA *event2 = new EventA(10);
//const EventB eventb("Hello world");
/*Send a subscribe to the bus*/
bus.subscribe<EventA>(this);
pub.Publish<EventA>(*event);
pub.Publish<EventA>(*event2);
std::cout<<"notified"<<std::endl;
}
void FooB::RunTestSyn() {
std::cout << "FooRunningFooB" << std::endl;
EventA *event = new EventA(5);
EventA *event2 = new EventA(10);
EventB *event2b = new EventB("Hello world!!");
Publisher pub(synch);
std::cout << "after FooRunningFoo" << std::endl;
/*Send a subscribe to the bus*/
bus.subscribe<EventA>(this);
bus.subscribe<EventB>(this);
pub.Publish<EventA>(*event);
pub.Publish<EventB>(*event2b);
std::cout<<"notified"<<std::endl;
}
void FooB::RunTestAsyn() {
std::cout << "FooRunningFooB" << std::endl;
EventA *event = new EventA(5);
EventA *event2 = new EventA(10);
EventB *event2b = new EventB("Hello world!!");
Publisher pub(principal);
std::cout << "after FooRunningFoo" << std::endl;
/*Send a subscribe to the bus*/
bus.subscribe<EventA>(this);
bus.subscribe<EventB>(this);
pub.Publish<EventA>(*event);
pub.Publish<EventB>(*event2b);
std::cout<<"notified"<<std::endl;
}