C++, C#, and Java Implementations

View as MarkdownOpen in Claude

For C#, Java, C++, and Visual Basic, we instead maintain a triple thread structure which requires the creation of a reader thread, a queue thread, and then a wrapper thread. The documentation listed here further elaborates on the structure for those languages.

1final EReader reader = new EReader(m_client, m_signal);
2
3reader.start();
4//An additional thread is created in this program design to empty the messaging queue
5new Thread(() -> {
6 while (m_client.isConnected()) {
7 m_signal.waitForSignal();
8 try {
9 reader.processMsgs();
10 } catch (Exception e) {
11 System.out.println("Exception: "+e.getMessage());
12 }
13 }
14}).start();

Now it is time to revisit the role of IBApi.EReaderSignal initially introduced in The EClientSocket Class. As mentioned in the previous paragraph, after the EReader thread places a message in the queue, a notification is issued to make known that a message is ready for processing. In the (C++, C#/.NET, Java) APIs, this is done via the IBApi.EReaderSignal object we initiated within the IBApi.EWrapper’s implementer.