Commit b1c892d9b984239c8cf7abd949a60af4549bbc6f
1 parent
dd97a648
Modifications for usage of new queue code.
Showing
5 changed files
with
11 additions
and
10 deletions
... | ... | @@ -46,7 +46,7 @@ static void eventDtor(void * _this) |
46 | 46 | TR_Event this = _this; |
47 | 47 | |
48 | 48 | this->subject->emitted = |
49 | - this->subject->emitted == 0 | |
49 | + this->subject->emitted == 0 | |
50 | 50 | ? 0 : this->subject->emitted - 1; |
51 | 51 | |
52 | 52 | if (0 == this->subject->emitted && this->subject->fin) { | ... | ... |
... | ... | @@ -40,9 +40,10 @@ doRegister(const void * _node, const void * data) |
40 | 40 | |
41 | 41 | if (handler_queue_hv) { |
42 | 42 | handler_queue = *(TR_Queue *)handler_queue_hv->value; |
43 | - } else { | |
43 | + } else { | |
44 | 44 | handler_queue = TR_new(TR_Queue); |
45 | 45 | handler_queue->free_msgs = 0; |
46 | + // TODO change TR_Queue to TR_Dynarray as this is no queue. | |
46 | 47 | handler_queue_hv = TR_new( |
47 | 48 | TR_HashValue, |
48 | 49 | node->key, | ... | ... |
... | ... | @@ -69,18 +69,18 @@ TR_eventDispatcherStart(TR_EventDispatcher this) |
69 | 69 | ? *(TR_Queue *)handler_queue_hv->value |
70 | 70 | : NULL; |
71 | 71 | |
72 | - if (handler_queue && ! TR_queueEmpty(handler_queue)) { | |
73 | - TR_Queue queue_node = handler_queue->first; | |
74 | - TR_EventDone done = TR_EVENT_PENDING; | |
72 | + if (handler_queue) { | |
73 | + size_t idx = TR_queueFirst(handler_queue); | |
74 | + TR_EventDone done = TR_EVENT_PENDING; | |
75 | 75 | |
76 | - while (queue_node) { | |
77 | - TR_EventHandler handler = queue_node->msg; | |
76 | + while (idx != TR_queueLast(handler_queue)) { | |
77 | + TR_EventHandler handler = handler_queue->data[idx]; | |
78 | 78 | TR_EventDone this_done; |
79 | 79 | |
80 | 80 | this_done = TR_eventHandlerHandleEvent(handler, event); |
81 | 81 | done = TR_EVENT_DONE == done ? done : this_done; |
82 | 82 | |
83 | - queue_node = queue_node->next; | |
83 | + idx = idx + 1 == TR_queueSize(handler_queue) ? 0 : idx + 1; | |
84 | 84 | } |
85 | 85 | |
86 | 86 | if (TR_EVENT_DONE == done) { | ... | ... |
... | ... | @@ -39,7 +39,7 @@ TR_eventHandlerHandleEvent(TR_EventHandler this, TR_Event event) |
39 | 39 | |
40 | 40 | TR_loggerLog(TR_logger, TR_LOGGER_DEBUG, |
41 | 41 | "%zd - HANDLE(%zd): %s event on %p with no. %d", |
42 | - this->dispatcher[0]->events->nmsg, | |
42 | + TR_queueSize(this->dispatcher[0]->events), | |
43 | 43 | event->subject->emitted, |
44 | 44 | TR_getEventString(event), |
45 | 45 | event->subject, | ... | ... |
... | ... | @@ -38,7 +38,7 @@ TR_eventHandlerIssueEvent(TR_EventHandler this, TR_Event event) |
38 | 38 | |
39 | 39 | TR_loggerLog(TR_logger, TR_LOGGER_DEBUG, |
40 | 40 | "%zd - ISSUE(%zd): %s event on %p with no. %d", |
41 | - this->dispatcher[i]->events->nmsg, | |
41 | + TR_queueSize(this->dispatcher[i]->events), | |
42 | 42 | event->subject->emitted, |
43 | 43 | TR_getEventString(event), |
44 | 44 | event->subject, | ... | ... |
Please
register
or
login
to post a comment