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 53 int running;
54 54 int heartbeat; // milliseconds
55 55 int nextbeat; // milliseconds
  56 + size_t n_beats;
56 57 TR_EventDispatcherMode mode;
57 58 };
58 59 TR_INSTANCE_INIT(TR_EventDispatcher);
... ...
... ... @@ -48,7 +48,8 @@ TR_eventDispatcherStart(TR_EventDispatcher this)
48 48 now = tp.tv_sec * 1000 + tp.tv_nsec / 1000000;
49 49
50 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 53 event = TR_eventSubjectEmit(
53 54 (TR_EventSubject)this,
54 55 TR_DISPATCHER_EVENT_HEARTBEAT,
... ...
... ... @@ -38,8 +38,9 @@ TR_eventHandlerHandleEvent(TR_EventHandler this, TR_Event event)
38 38 TR_sdbm((unsigned char *)&event->id, sizeof(event->id)));
39 39
40 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 42 this->dispatcher[0]->events->nmsg,
  43 + event->subject->emitted,
43 44 TR_getEventString(event),
44 45 event->subject,
45 46 event->serial);
... ...
... ... @@ -37,8 +37,9 @@ TR_eventHandlerIssueEvent(TR_EventHandler this, TR_Event event)
37 37 TR_eventDispatcherEnqueueEvent(this->dispatcher[i], event);
38 38
39 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 41 this->dispatcher[i]->events->nmsg,
  42 + event->subject->emitted,
42 43 TR_getEventString(event),
43 44 event->subject,
44 45 event->serial);
... ...
Please register or login to post a comment