What is the correct code flow while sending a message

1

I have a fundamental doubt wrt boost signaling used in bitcoin. As far as I understand the following happens between main.cpp and init.cpp:

  • StartNode() spawns a thread ThreadMessageHandler
  • ThreadMessageHandler issues a boost signal SendMessages
  • SendMessages() does the sending of messages (like PING or INV)

Is my understanding correct? Why do we invoke a boost signal and complicate ? Why not a simple function call to SendMessages() in main.cpp would not do the equivalent?

Any expert please explain the flow of code here.

Update

Code Snippet1 (Original Bitcoin)

if (lockSend)
     g_signals.SendMessages(pnode);

Code Snippet2 (My Attempt):

if (lockSend)
     SendMessages(pnode);

Guhan S

Posted 2016-01-08T06:53:32.727

Reputation: 85

When would you call it?David Schwartz 2016-01-08T08:00:08.043

Please see my update (Snippets). Is that not equivalent? Anyway there are some checks inside ProcessMessages() after which real messages are pushed. Like for Ping to happen -- one will need wait till PING_INTERVAL or manually issue it. All these are anyway checked in the function.Guhan S 2016-01-08T08:55:00.507

No answers