OnixS C++ CME MDP Premium Market Data Handler  5.8.9
API Documentation
SocketFeedEngine.h
Go to the documentation of this file.
1 // Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2 //
3 // This software owned by Onix Solutions Limited [OnixS] and is
4 // protected by copyright law and international copyright treaties.
5 //
6 // Access to and use of the software is governed by the terms of the applicable
7 // OnixS Software Services Agreement (the Agreement) and Customer end user license
8 // agreements granting a non-assignable, non-transferable and non-exclusive license
9 // to use the software for it's own data processing purposes under the terms defined
10 // in the Agreement.
11 //
12 // Except as otherwise granted within the terms of the Agreement, copying or
13 // reproduction of any part of this source code or associated reference material
14 // to any other location for further reproduction or redistribution, and any
15 // amendments to this copyright notice, are expressly prohibited.
16 //
17 // Any reproduction or redistribution for sale or hiring of the Software not in
18 // accordance with the terms of the Agreement is a violation of copyright law.
19 //
20 
21 #pragma once
22 
23 #include <OnixS/CME/MDH/Watch.h>
26 
28 
29 /// Represents a collection of settings affecting
30 /// the behavior of the multi-threaded feed engine
31 /// while working with network-related services.
33 {
34 public:
35  /// Initializes the given instance of the
36  /// network settings with the default values.
38  : packetMaxSize_(1420)
39  , watch_(&UtcWatch::service())
40  , socketBufferSize_(8 * 1024 * 1024)
41  , dataWaitTime_(10)
42  {
43  }
44 
45  /// Cleans everything up.
47 
48  /// Max size for network packet transmitted by MDP.
49  ///
50  /// @note Default value is '1420'.
52  {
53  return packetMaxSize_;
54  }
55 
56  /// Max size for network packet transmitted by MDP.
58  {
59  packetMaxSize_ = value;
60  }
61 
62  /// Watch service to be used by Feed Engine.
63  ///
64  /// Watch is used by Feed Engine to assign time
65  /// points to packets received from the feeds.
66  ///
67  /// @note By default, UTC watch service is used.
69  {
70  return *watch_;
71  }
72 
73  /// Watch service to be used by Feed Engine.
74  ///
75  /// If no instance associated, UTC watch is used.
76  void watch(WatchService& watch)
77  {
78  watch_ = &watch;
79  }
80 
81  /// Defines size of receiving buffer in bytes for sockets.
82  ///
83  /// @note Default value is 8 MiB.
85  {
86  return socketBufferSize_;
87  }
88 
89  /// Sets socketBufferSize. @see socketBufferSize.
91  {
92  socketBufferSize_ = value;
93  }
94 
95  /// Defines amount of time Feed Engine spends on socket
96  /// waiting for I/O while running master processing loop.
97  ///
98  /// Time is measured in milliseconds.
99  ///
100  /// @note Default value is '10'.
101  ///
102  /// @warning The given parameter significantly affects
103  /// responsiveness of the Handler and load onto CPU.
105  {
106  return dataWaitTime_;
107  }
108 
109  /// Sets dataWaitTime. @see dataWaitTime.
111  {
112  dataWaitTime_ = value;
113  }
114 
115 private:
116  PacketSize packetMaxSize_;
117  WatchService* watch_;
118 
119  UInt32 socketBufferSize_;
120  UInt32 dataWaitTime_;
121 };
122 
123 /// Serializes feed engine settings into a string.
125 void toStr(std::string&, const SocketFeedEngineSettings&);
126 
127 /// Serializes feed engine settings into a string.
128 inline std::string toStr(const SocketFeedEngineSettings& settings)
129 {
130  std::string str;
131 
132  toStr(str, settings);
133 
134  return str;
135 }
136 
137 /// The given class implements feed engine concept
138 /// using pool of working threads and standard socket
139 /// API.
141 {
142 public:
143  /// Initializes the engine according to the given configuration.
145 
146  /// Initializes the engine with the default settings
148 
149  /// Destructs the given instance.
151 
152  /// Appends information on the given
153  /// implementation to the given string.
154  void info(std::string&) ONIXS_CMEMDH_OVERRIDE;
155 
156  /// Allocates a link for the given feed.
157  NetFeedLink& allocate(const NetFeed&) ONIXS_CMEMDH_OVERRIDE;
158 
159  /// Exposes an instance of the watch service
160  /// used while manipulating the feed links.
162 
163  /// Carries out pending actions like
164  /// data retrieval and event dispatching.
165  ///
166  /// The returned value indicates whether any
167  /// events have been handled by the engine.
169 
170 private:
171  // The workhorse for the multi-threaded
172  // feed engine based on the standard socket
173  // API and a pool of threads.
174  class Workhorse;
175 
176  Workhorse* workhorse_;
177 };
178 
Designed to reflect various aspects of feed engine processing flow.
Definition: FeedEngine.h:35
std::string toStr(const SocketFeedEngineSettings &settings)
Serializes feed engine settings into a string.
#define ONIXS_CMEMDH_OVERRIDE
Definition: Compiler.h:165
void dataWaitTime(UInt32 value)
Sets dataWaitTime.
UInt32 UInt32
uInt32.
Definition: Fields.h:192
The given class implements feed engine concept using pool of working threads and standard socket API...
void socketBufferSize(UInt32 value)
Sets socketBufferSize.
Represents a collection of settings affecting the behavior of the multi-threaded feed engine while wo...
UInt32 dataWaitTime() const
Defines amount of time Feed Engine spends on socket waiting for I/O while running master processing l...
Abstract watch service.
Definition: Watch.h:29
#define ONIXS_CMEMDH_LTWT
Definition: Bootstrap.h:46
Abstraction for the Feed Engine machinery.
Definition: FeedEngine.h:101
void packetMaxSize(PacketSize value)
Max size for network packet transmitted by MDP.
bool process(NetFeedEngine &engine)
Carries out pending actions like data retrieval and event dispatching.
Definition: FeedEngine.h:146
UInt32 socketBufferSize() const
Defines size of receiving buffer in bytes for sockets.
SocketFeedEngineSettings()
Initializes the given instance of the network settings with the default values.
bool value(Number &number, const MultiContainer &container, Tag tag)
Finds a tag-value entry in the given collection by the given tag and returns its value component tran...
Base attributes of market data feed.
Definition: Feed.h:54
WatchService & watch() const
Watch service to be used by Feed Engine.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:67
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:160
~SocketFeedEngineSettings()
Cleans everything up.
PacketSize packetMaxSize() const
Max size for network packet transmitted by MDP.
UInt16 PacketSize
Integral type for measuring packets.
Definition: PacketTraits.h:32
void watch(WatchService &watch)
Watch service to be used by Feed Engine.
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:68