|
|
|
@ -30,6 +30,8 @@ |
|
|
|
#include "tr/event_subject.h" |
|
|
|
#include "tr/event_dispatcher.h" |
|
|
|
|
|
|
|
int ZERO = 0; |
|
|
|
|
|
|
|
void |
|
|
|
TR_eventDispatcherStart(TR_EventDispatcher this) |
|
|
|
{ |
|
|
|
@ -55,18 +57,14 @@ TR_eventDispatcherStart(TR_EventDispatcher this) |
|
|
|
NULL)); |
|
|
|
} |
|
|
|
|
|
|
|
if (TR_queueEmpty(this->events)) { |
|
|
|
if (TR_EVD_CLIENT == this->mode) { |
|
|
|
event = TR_eventSubjectEmit( |
|
|
|
(TR_EventSubject)this, |
|
|
|
TR_DISPATCHER_EVENT_USER_WAIT, |
|
|
|
NULL); |
|
|
|
} else { |
|
|
|
event = TR_eventSubjectEmit( |
|
|
|
(TR_EventSubject)this, |
|
|
|
TR_DISPATCHER_EVENT_DATA_WAIT, |
|
|
|
NULL); |
|
|
|
} |
|
|
|
if (TR_queueEmpty(this->events) || this->nextpoll <= now) { |
|
|
|
int evtid = TR_EVD_CLIENT == this->mode |
|
|
|
? TR_DISPATCHER_EVENT_USER_WAIT |
|
|
|
: TR_DISPATCHER_EVENT_DATA_WAIT; |
|
|
|
int * toutptr = TR_queueEmpty(this->events) ? NULL : &ZERO; |
|
|
|
|
|
|
|
this->nextpoll += this->pollinterval; |
|
|
|
event = TR_eventSubjectEmit((TR_EventSubject)this, evtid, toutptr); |
|
|
|
} else { |
|
|
|
event = TR_queueGet(this->events); |
|
|
|
} |
|
|
|
@ -83,7 +81,7 @@ TR_eventDispatcherStart(TR_EventDispatcher this) |
|
|
|
|
|
|
|
if (handler_queue && ! TR_queueEmpty(handler_queue)) { |
|
|
|
TR_Queue queue_node = handler_queue->first; |
|
|
|
TR_EventDone done; |
|
|
|
TR_EventDone done = TR_EVENT_PENDING; |
|
|
|
|
|
|
|
while (queue_node) { |
|
|
|
TR_EventHandler handler = queue_node->msg; |
|
|
|
|