Commit 2c2cb317e513309b6c7dbc29e6bb46e138c4d88c
1 parent
8fb77893
keep track of the anount of pending events on a subject
Showing
3 changed files
with
13 additions
and
2 deletions
... | ... | @@ -28,7 +28,9 @@ |
28 | 28 | |
29 | 29 | #include "trbase.h" |
30 | 30 | |
31 | -TR_CLASS(TR_EventSubject) {}; | |
31 | +TR_CLASS(TR_EventSubject) { | |
32 | + size_t emitted; | |
33 | +}; | |
32 | 34 | TR_INSTANCE_INIT(TR_EventSubject); |
33 | 35 | TR_CLASSVARS_DECL(TR_EventSubject) { |
34 | 36 | size_t nevents; |
... | ... | @@ -48,6 +50,8 @@ TR_CLASSVARS_DECL(TR_EventSubject) { |
48 | 50 | #define TR_eventSubjectGetId(obj, idx) \ |
49 | 51 | TR__eventSubjectId(TR_GET_CLASS(obj), idx) |
50 | 52 | |
53 | +#define TR_eventSubjectHasUnhandledEvents(es) ((es)->emitted > 0) | |
54 | + | |
51 | 55 | intptr_t TR__eventSubjectId(TR_class_ptr, size_t); |
52 | 56 | TR_Event TR_eventSubjectEmit(TR_EventSubject, int, void *); |
53 | 57 | ... | ... |
... | ... | @@ -41,7 +41,12 @@ eventCtor(void * _this, va_list * params) |
41 | 41 | return 0; |
42 | 42 | } |
43 | 43 | |
44 | -static void eventDtor(void * _this) {} | |
44 | +static void eventDtor(void * _this) | |
45 | +{ | |
46 | + TR_Event this = _this; | |
47 | + | |
48 | + this->subject->emitted--; | |
49 | +} | |
45 | 50 | |
46 | 51 | TR_INIT_IFACE(TR_Class, eventCtor, eventDtor, NULL); |
47 | 52 | TR_CREATE_CLASS(TR_Event, NULL, NULL, TR_IF(TR_Class)) = { 0 }; | ... | ... |
Please
register
or
login
to post a comment