Pregunta

Most ticks are fine, but quite often some ticks are missing

Pseudo code:

    Foreach Message msg in myEvent
    {
       if (m.hasField(BID))
       {
            handlebid(m.getFieldasFloat64(BID);
       }

       if (m.hasField(BID_SIZE))
       {

           int bidsize=m.getFieldasInt(BID_SIZE);
           if (bidsize==0)
           {
                  return -1;
           }
           handlebidsize(bidsize);
      }

      if (m.hasField(ASK))
      {
           handleask(m.getFieldasFloat64(ASK);
      }

      if (m.hasField(ASK_SIZE))
      {
           int asksize=m.getFieldasInt(ASK_SIZE);
           if (asksize==0)
           {
                  return -1;
           }
           handleasksize(asksize);
      }
}
¿Fue útil?

Solución

Events can contain multiple messages

If your event handler does a return or breaks out of the loop in any way instead of going to the next loop iteration, then any messages in the event after the one that triggered the loop exit will not be processed. Any ticks in those messages will be "dropped"

Never exit an event processing loop with return or break

Otros consejos

Glenn Teitelbaum is correct, an event can contain multiple messages. Another reason you could be dropping ticks is that one request could result in multiple responses: several partial responses and one response. Make sure you handle both types of responses and that you call nextEvent() till you get a response event (instead of partial response).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top