I'm trying to reason about the c++ TWS API, and according to the documentation
One thread is used for sending messages to TWS, and another thread is used for reading returned messages. The second thread uses the API EReader class to read from the socket and add messages to a queue. Everytime a new message is added to the message queue, a notification flag is triggered to let other threads now that there is a message waiting to be processed. In the two-thread design of an API program, the message queue is also processed by the first thread.
I'm trying to modify variables in callbacks that read information, and read them to send messages in other methods. Here are my questions:
1. Each callback is only controlled by one and only one thread, I hope. Is that right?
2. std::unique_ptr<EReader> m_pReader is the subordinate thread that triggers all these pure virtual methods that report information from TWS, right? The main thread calls methods explicitly in TestCppClient's definition, and I can see those.
3.? EClientSocket * const m_pClient sends information *to* TWS, but uses the same shared data structure as m_pReader (they both look at EReaderOSSignal m_osSignal, for example)? Is all the shared stuff written by IBKR thread safe? I think I would've heard about it by now they weren't. That would be pretty crazy.