OnixS C++ CME Market Data Handler  5.4.0
API documentation
SolarflareFeedEngine.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 feed engine while working
31 /// with virtual interfaces.
34 {
35  UInt32 receiveRingSize_;
36  UInt32 cacheSize_;
37 
38  WatchService* watch_;
39 
40 public:
41  /// Initializes the given instance of the
42  /// network settings with the default values.
44  : receiveRingSize_(
45  static_cast<UInt32>(-1))
46  , cacheSize_(1024)
47  , watch_(
48  &UtcWatch::service())
49  {
50  }
51 
52  /// Cleans everything up.
54  {
55  }
56 
57  /// Number of buffers in a virtual interface receive ring.
58  ///
59  /// Single buffer is used for a single network packet.
60  /// Thus the receive ring must be capacious enough to
61  /// place incoming packets during market data bursts.
62  ///
63  /// By default, the parameter is set to '-1' which means
64  /// receive ring will be constructed of the default capacity.
65  UInt32
67  {
68  return receiveRingSize_;
69  }
70 
71  /// Number of buffers in a virtual interface receive ring.
72  ///
73  /// Single buffer is used for a single network packet.
74  /// Thus the receive ring must be capacious enough to
75  /// place incoming packets during market data bursts.
76  ///
77  /// By default, the parameter is set to '-1' which means
78  /// receive ring will be constructed of the default capacity.
79  void
81  UInt32 ringSize)
82  {
83  receiveRingSize_ = ringSize;
84  }
85 
86  /// Size of a pool of buffers used to
87  /// receive and manipulate incoming data.
88  ///
89  /// The feed engine puts incoming packets into buffers
90  /// and keeps buffers busy until received data is processed
91  /// by handlers. In case of rapid transmission, buffers may
92  /// be allocated quicker than they are processed and released
93  /// back to pool. Therefore, the pool must be capacious enough
94  /// to avoid data losses.
95  UInt32
96  cacheSize() const
97  {
98  return cacheSize_;
99  }
100 
101  /// Size of pool of buffers used to
102  /// receive and manipulate incoming data.
103  void
105  UInt32 cacheSize)
106  {
107  cacheSize_ = cacheSize;
108  }
109 
110  /// Watch service to be used by Feed Engine.
111  ///
112  /// Watch is used by Feed Engine to assign time
113  /// points to packets received from the feeds.
114  ///
115  /// @note By default, UTC watch service is used.
117  {
118  return *watch_;
119  }
120 
121  /// Watch service to be used by Feed Engine.
122  ///
123  /// If no instance associated, UTC watch is used.
124  void
126  WatchService& watch)
127  {
128  watch_ = &watch;
129  }
130 };
131 
132 /// Serializes feed engine settings into a string.
133 ONIXS_CMEMDH_EXPORTED
134 void
135 toStr(
136  std::string&,
137  const
139 
140 /// Serializes feed engine settings into a string.
141 inline
142 std::string
144  const
146 {
147  std::string str;
148 
149  toStr(str, settings);
150 
151  return str;
152 }
153 
154 /// The given class implements feed engine concept
155 /// using pool of working threads and standard socket
156 /// API.
159  : public NetFeedEngine
160 {
161  // The workhorse for the feed engine.
162  class Workhorse;
163 
164  Workhorse* workhorse_;
165 
166 public:
167  /// Initializes the engine according to the given configuration.
170 
171  /// Destructs the given instance.
173 
174  /// Appends information on the given
175  /// implementation to the given string.
176  void
177  info(
178  std::string&);
179 
180  /// Allocates a link for the given feed.
181  NetFeedLink&
182  allocate(
183  const NetFeed&);
184 
185  /// Exposes a watch service used
186  /// while manipulating the feed links.
187  WatchService&
188  watch();
189 
190  /// Carries out pending actions like
191  /// data retrival and event dispatching.
192  virtual
194  process();
195 };
196 
#define ONIXS_CMEMDH_LTWT_CLASS
Definition: Bootstrap.h:94
UInt32 UInt32
uInt32.
Definition: Fields.h:247
Abstract watch service.
Definition: Watch.h:29
bool process(NetFeedEngine &engine)
Definition: FeedEngine.h:183
Base attributes of market data feed.
Definition: Feed.h:60
#define ONIXS_CMEMDH_EXPORTED_CLASS
Definition: Bootstrap.h:54
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:152
std::string toStr(const SolarflareFeedEngineSettings &settings)
Serializes feed engine settings into a string.
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:156