OnixS C++ CME Market Data Handler  5.4.0
API documentation
User Defined Watch Service

By default, the Handler uses a precise watch returning UTC (Universal Time Coordinated) time. The SDK exposes the given watch service as the OnixS::CME::MDH::UtcWatch class. It's used by the default implementation of the Feed Engine concept to assign the receive time for incoming data and to determine timeouts. File-based implementation of the Logger abstraction also uses the noted watch to label logged events.

However, the SDK allows switching using a different watch including the custom implementation providing faster or more precise timing. For this reason, the SDK exposes the OnixS::CME::MDH::WatchService abstract class. Users may bind its instances to the other services requiring a watch like the Feed Engine or the Logger.

A custom watch must be derived from the OnixS::CME::MDH::WatchService class. Afterwards, an instance of a derived descendant must be associated with a corresponding service.

The following code depicts how to make the OnixS::CME::MDH::MultithreadedFeedEngine to timestamp packets in local time. The SDK includes ready-to-use implementation of a watch returning local time. Therefore, an instance of a local watch is always available for the users.

// Watch returning local time is always available.
WatchService& localWatch = LocalWatch::service();
MultithreadedFeedEngineSettings mtfeSettings;
The OnixS::CME::MDH::MultithreadedFeedEngine uses multiple threads as well as Logger implementations may be multi-threaded. Therefore, OnixS::CME::MDH::WatchService::now can be called concurrently and thus it must be thread safe.

The Timestamp Internals

OnixS::CME::MDH::WatchService::now returns time as an instance of the OnixS::CME::MDH::Timestamp class. Internally the OnixS::CME::MDH::Timestamp corresponds to CME MDH timestamp representation using unsigned 64-bit integer storing a number of nanoseconds since the Unix Epoch (01-01-1970 00:00:00 UTC). Thus, the most effective way to construct an instance of the class is to pass a number of nanoseconds since the Epoch.