The FIX Engine supports the following threading models for usual sockets:
The OnixS::FIX::ThreadingModel::ExternalThread mode supports the Solarflare TCPDirect technology that is described in the Solarflare TCPDirect section.
The model is configured via the OnixS::FIX::EngineSettings::threadingModel(ThreadingModel::Enum value) method.
If this mode is used and there is an active connection the FIX Engine creates receiving and sending threads on each session instance. The receiving thread receives and processes incoming FIX messages. The sending thread processes user's FIX messages which were stored in the internal sending queue. The OnixS::FIX::Session::messageGrouping parameter affects the sending process. If the parameter is zero (by default) or one, the FIX Engine tries to send a FIX message in the primary application thread and only after a failure, stores it in the sending queue for the next process in the sending thread. If the parameter is greater than one the FIX Engine stores a FIX message in the sending queue immediately and then processes it in the sending thread.
The following table explains which callbacks could be called by the each one thread.
Callback | Primary application thread | Sending thread | Receiving thread |
OnixS::FIX::ISessionListener::onError | No | Yes | Yes |
OnixS::FIX::ISessionListener::onInboundApplicationMsg | No | No | Yes |
OnixS::FIX::ISessionListener::onInboundSessionMsg | No | No | Yes |
OnixS::FIX::ISessionListener::onOutboundApplicationMsg | Yes | Yes | No |
OnixS::FIX::ISessionListener::onOutboundSessionMsg | Yes | Yes | Yes |
OnixS::FIX::ISessionListener::onReceivedBytes | No | No | Yes |
OnixS::FIX::ISessionListener::onMessageSending | Yes | Yes | Yes |
OnixS::FIX::ISessionListener::onResendRequest | No | No | Yes |
OnixS::FIX::ISessionListener::onResendingStarted | No | No | Yes |
OnixS::FIX::ISessionListener::onResendingFinished | No | No | Yes |
OnixS::FIX::ISessionListener::onStateChange | Yes | Yes | Yes |
OnixS::FIX::ISessionListener::onWarning | Yes | Yes | Yes |
If this mode is used the FIX Engine creates the thread pool and shares it between all sessions. The maximum threads number in the thread pool depends on the OnixS::FIX::EngineSettings::threadPoolSize parameter. The default value(0) of this parameter means that the thread pool's size will equal the CPUs number. One thread, in the thread pool, performs read/write operations and can process some number of different FIX connections. FIX connections are distributed equally between all threads.
In OnixS::FIX::ThreadingModel::ExternalThread mode the FIX Engine does not create I/O threads. Such mode means that user creates additional threads himself (or uses the main thread), then performs event dispatching in a loop by calling the OnixS::FIX::ISessionReactor::dispatchEvents() routine. This mode supports the Solarflare's TCPDirect and regular TCP connections. For TCPDirect connections, one should use the OnixS::FIX::TCPDirect::Stack as a reactor. For regular TCP connections, one should use OnixS::FIX::TCPStandard::Stack as a reactor.