Commit 564e2f30408d85ac68db5b7a524d45a20adbf850

Authored by Georg Hopp
1 parent f453af49

trigger heartbeat with a factor of missed heartbeats instead of multiple times. Change logging a bit

@@ -53,6 +53,7 @@ TR_CLASS(TR_EventDispatcher) { @@ -53,6 +53,7 @@ TR_CLASS(TR_EventDispatcher) {
53 int running; 53 int running;
54 int heartbeat; // milliseconds 54 int heartbeat; // milliseconds
55 int nextbeat; // milliseconds 55 int nextbeat; // milliseconds
  56 + size_t n_beats;
56 TR_EventDispatcherMode mode; 57 TR_EventDispatcherMode mode;
57 }; 58 };
58 TR_INSTANCE_INIT(TR_EventDispatcher); 59 TR_INSTANCE_INIT(TR_EventDispatcher);
@@ -48,7 +48,8 @@ TR_eventDispatcherStart(TR_EventDispatcher this) @@ -48,7 +48,8 @@ TR_eventDispatcherStart(TR_EventDispatcher this)
48 now = tp.tv_sec * 1000 + tp.tv_nsec / 1000000; 48 now = tp.tv_sec * 1000 + tp.tv_nsec / 1000000;
49 49
50 if (this->nextbeat && this->nextbeat <= now) { 50 if (this->nextbeat && this->nextbeat <= now) {
51 - this->nextbeat += this->heartbeat; 51 + this->n_beats = ((now - this->nextbeat) / this->heartbeat) + 1;
  52 + this->nextbeat += this->n_beats * this->heartbeat;
52 event = TR_eventSubjectEmit( 53 event = TR_eventSubjectEmit(
53 (TR_EventSubject)this, 54 (TR_EventSubject)this,
54 TR_DISPATCHER_EVENT_HEARTBEAT, 55 TR_DISPATCHER_EVENT_HEARTBEAT,
@@ -38,8 +38,9 @@ TR_eventHandlerHandleEvent(TR_EventHandler this, TR_Event event) @@ -38,8 +38,9 @@ TR_eventHandlerHandleEvent(TR_EventHandler this, TR_Event event)
38 TR_sdbm((unsigned char *)&event->id, sizeof(event->id))); 38 TR_sdbm((unsigned char *)&event->id, sizeof(event->id)));
39 39
40 TR_loggerLog(TR_logger, TR_LOGGER_DEBUG, 40 TR_loggerLog(TR_logger, TR_LOGGER_DEBUG,
41 - "%zd - HANDLE: %s event on %p with no. %d", 41 + "%zd - HANDLE(%zd): %s event on %p with no. %d",
42 this->dispatcher[0]->events->nmsg, 42 this->dispatcher[0]->events->nmsg,
  43 + event->subject->emitted,
43 TR_getEventString(event), 44 TR_getEventString(event),
44 event->subject, 45 event->subject,
45 event->serial); 46 event->serial);
@@ -37,8 +37,9 @@ TR_eventHandlerIssueEvent(TR_EventHandler this, TR_Event event) @@ -37,8 +37,9 @@ TR_eventHandlerIssueEvent(TR_EventHandler this, TR_Event event)
37 TR_eventDispatcherEnqueueEvent(this->dispatcher[i], event); 37 TR_eventDispatcherEnqueueEvent(this->dispatcher[i], event);
38 38
39 TR_loggerLog(TR_logger, TR_LOGGER_DEBUG, 39 TR_loggerLog(TR_logger, TR_LOGGER_DEBUG,
40 - "%zd - ISSUE: %s event on %p with no. %d", 40 + "%zd - ISSUE(%zd): %s event on %p with no. %d",
41 this->dispatcher[i]->events->nmsg, 41 this->dispatcher[i]->events->nmsg,
  42 + event->subject->emitted,
42 TR_getEventString(event), 43 TR_getEventString(event),
43 event->subject, 44 event->subject,
44 event->serial); 45 event->serial);
Please register or login to post a comment