OnixS C++ CBOE CFE Binary Order Entry (BOE) Handler 1.12.0
API documentation
Loading...
Searching...
No Matches
Advanced Programming

This section provides information about more advanced development techniques supported by the Handler.

Handler States

To get understanding in which state the Handler currently is, it's necessary to implement the OnixS::CboeCFE::Trading::BOE::HandlerStateListener class interface and associate an instance with the Handler using OnixS::CboeCFE::Trading::BOE::Handler::registerHandlerStateListener member.

The table below describes all possible states for the Handler:

StateDescription
OnixS::CboeCFE::Trading::BOE::HandlerState::DisconnectedHandler is disconnected or was not executed yet.
OnixS::CboeCFE::Trading::BOE::HandlerState::DisconnectingThe intermediate state when the Handler is not disconnected but not connected.
OnixS::CboeCFE::Trading::BOE::HandlerState::ConnectedHandler is connected.
OnixS::CboeCFE::Trading::BOE::HandlerState::ConnectingThe intermediate state when the Handler is not connected but not disconnected.

Controlling Logging in the Handler

The Handler logs an important aspects of its execution into the directory specified by the OnixS::CboeCFE::Trading::BOE::HandlerSettings::logDirectory member value. Logging includes network data received and processed by the Handler and, of course, errors occurred at execution time.

Since the Handler outputs logging data into regular files, this affects its performance and sometimes requires significant system resources like space on hard drive. The Handler exposes several parameters which allow to suppress certain kind of logging data and thus reduce load to the file system as well as to increase general performance.

Following table describes logging-related parameters exposed by the OnixS::CboeCFE::Trading::BOE::HandlerSettings structure:

Settings MemberDefault valueDescription
logLevelOnixS::CboeCFE::Trading::BOE::LogLevel::InfoSpecifies whether the Handler must output informational messages about its state as well as which kind of information must be put into the log. For more information, please, take a look at the description of OnixS::CboeCFE::Trading::BOE::LogLevel enumeration entries.
logSettingsOnixS::CboeCFE::Trading::BOE::LogSettings::DefaultIf logging is activated, this member specifies which additional data must be put into the log. For more information, please, take a look at the description of OnixS::CboeCFE::Trading::BOE::LogSettings enumeration entries.

Activating Logging Example

Following example demonstrates how to enable logging in the Handler:

HandlerSetting settings;
// Activate logging.
settings.logMode = LogModes::Debug;
// Don't forget to define folder where logs to be stored.
settings.logDirectory = "./logs";
// In addition to standard information, decoded messages will be logged.
settings.logSettings = LogSettings::DumpProtocolText;

Asynchronous logging

The Handler provides an asynchronous logging facility. Asynchronous logging is the way to go to minimize file I/O latencies. Following example demonstrates how to enable asynchronous logging in the Handler:

HandlerSetting settings;
// Activate logging.
settings.logLevel = LogLevel::Info;
// Trace log messages to file asynchronously.
// Don't forget to define folder where logs to be stored.
settings.logDirectory = "./logs";

Threading Model

The Handler starts with two threads: one for sending messages and another for receiving messages.

One additional thread will be created if asynchronous logging facility is used. For more details please see Asynchronous logging section.

All callbacks of OnixS::CboeCFE::Trading::BOE::MessageListener are fired from one thread.

It is very important for user code to be as fast as possible in these callbacks to avoid delay with next message processing.

Low Latency Best Practices

Disable logging

Please use this code snippet to disable all logging operations:

// Available only log messages for fatal errors.
settings.logLevel = LogLevel::Fatal;
// Available only logging to file.
settings.logSettings = LogSettings::TraceToFile;

CPU affinity mask

Please use this code snippet to set processor affinity mask for sending and receiving threads.

// Sending thread will run on the 1st processor core.
settings.sendingThreadAffinity.insert(0);
// Receiving thread will run on the 2nd processor core.
settings.receivingThreadAffinity.insert(1);