OnixS C++ CME MDP Streamlined Market Data Handler 1.2.0
API Documentation
Loading...
Searching...
No Matches
FeedEngine.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
27
29
32
35{
36public:
38 typedef
41
44 {
45 }
46
49 const ThreadAffinity& other)
50 : indices_(other.indices_)
51 {
52 }
53
56 {
57 }
58
60 const CpuIndices& cpus() const
61 {
62 return indices_;
63 }
64
67 {
68 return indices_;
69 }
70
71private:
72 CpuIndices indices_;
73};
74
77void
79 std::string&,
80 const ThreadAffinity&);
81
83inline
84std::string
86 const ThreadAffinity& affinity)
87{
88 std::string str;
89
90 toStr(str, affinity);
91
92 return str;
93}
94
97{
98 ThreadAffinity threadAffinity_;
99 UInt32 threadCount_;
100
101 WatchService* watch_;
102
103 UInt32 dataWaitTime_;
104 UInt32 spinBeforeIdleTime_;
105
106 UInt32 socketBufferSize_;
107
108public:
111 : threadAffinity_()
112 , threadCount_(1)
113 , watch_(
114 &UtcWatch::service())
115 , dataWaitTime_(10)
116 , spinBeforeIdleTime_(1)
117 , socketBufferSize_(
118 8 * 1024 * 1024)
119 {
120 }
121
124 {
125 }
126
134 const
137 {
138 return threadAffinity_;
139 }
140
149 {
150 return threadAffinity_;
151 }
152
156 UInt32
158 {
159 return threadCount_;
160 }
161
163 void
165 UInt32 value)
166 {
167 threadCount_ = value;
168 }
169
177 {
178 return *watch_;
179 }
180
184 void
187 {
188 watch_ = &watch;
189 }
190
200 UInt32
202 {
203 return dataWaitTime_;
204 }
205
207 void
209 UInt32 value)
210 {
211 dataWaitTime_ = value;
212 }
213
222 UInt32
224 {
225 return spinBeforeIdleTime_;
226 }
227
229 void
231 UInt32 value)
232 {
233 spinBeforeIdleTime_ = value;
234 }
235
239 UInt32
241 {
242 return socketBufferSize_;
243 }
244
246 void
248 UInt32 value)
249 {
250 socketBufferSize_ = value;
251 }
252};
253
256void
258 std::string&,
259 const FeedEngineSettings&);
260
262inline
263std::string
265 const FeedEngineSettings& settings)
266{
267 std::string str;
268
269 toStr(str, settings);
270
271 return str;
272}
273
289
290//
291
293
300{
306 virtual
307 void
309 const FeedEngine&)
310 {
311 }
312
318 virtual
319 void
321 const FeedEngine&)
322 {
323 }
324
338 virtual
339 void
346
350 virtual
351 void
353 const FeedEngine&,
354 const Char*)
355 {
356 }
357};
358
359// Workhorse for the public Feed Engine.
361(
362 MultithreadedFeedEngine
363);
364
367{
368 // Current workhorse is multi-threaded
369 // feed engine using on socket API.
370 friend
372 (
374 );
375
377
378 // Copying is not supposed for given class.
379
380 FeedEngine(const FeedEngine&);
381 FeedEngine& operator =(const FeedEngine&);
382
383public:
386 const FeedEngineSettings&,
388
391
393 const
395 settings() const;
396};
397
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED_STRUCT
Definition Bootstrap.h:67
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED_CLASS_DECL(typeName)
Definition Bootstrap.h:55
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED_CLASS
Definition Bootstrap.h:63
#define ONIXS_CMESTREAMLINEDMDH_INTERNAL_CLASS_DECL(typeName)
Definition Bootstrap.h:71
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:169
#define ONIXS_CMESTREAMLINEDMDH_LTWT_STRUCT
Definition Bootstrap.h:115
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_END
Definition Bootstrap.h:173
#define ONIXS_CMESTREAMLINEDMDH_LTWT_CLASS
Definition Bootstrap.h:111
#define ONIXS_CMESTREAMLINEDMDH_EXPORTED
Definition Compiler.h:160
#define ONIXS_CMESTREAMLINEDMDH_NULLPTR
Definition Compiler.h:167
Collection of settings affecting Feed Engine behavior.
Definition FeedEngine.h:97
void threadCount(UInt32 value)
Sets threadsCount.
Definition FeedEngine.h:164
UInt32 spinBeforeIdleTime() const
Defines amount of time Feed Engine keeps cycling before going to sleep when no useful activity can be...
Definition FeedEngine.h:223
FeedEngineSettings()
Initializes options with default values.
Definition FeedEngine.h:110
ThreadAffinity & threadAffinity()
Defines set of CPUs allowed for each working thread to be executed on while processing market data by...
Definition FeedEngine.h:148
const ThreadAffinity & threadAffinity() const
Defines set of CPUs allowed for each working thread to be executed on while processing market data by...
Definition FeedEngine.h:136
void socketBufferSize(UInt32 value)
Sets udpSocketBufferSize.
Definition FeedEngine.h:247
void spinBeforeIdleTime(UInt32 value)
Sets redundancySpinTime.
Definition FeedEngine.h:230
void watch(WatchService &watch)
Watch service to be used by Feed Engine.
Definition FeedEngine.h:185
UInt32 dataWaitTime() const
Defines amount of time Feed Engine spends on socket waiting for I/O while running master processing l...
Definition FeedEngine.h:201
UInt32 threadCount() const
Number of working threads to be used by feed engine.
Definition FeedEngine.h:157
UInt32 socketBufferSize() const
Defines size of receiving buffer in bytes for sockets.
Definition FeedEngine.h:240
void dataWaitTime(UInt32 value)
Sets dataWaitTime.
Definition FeedEngine.h:208
WatchService & watch() const
Watch service to be used by Feed Engine.
Definition FeedEngine.h:176
Manages processing machinery for market data received from feeds.
Definition FeedEngine.h:367
const FeedEngineSettings & settings() const
Settings used define behavior of given instance.
FeedEngine(const FeedEngineSettings &, FeedEngineListener *=nullptr)
Initializes engine with given configuration.
~FeedEngine()
Destructs given instance.
Represents set of CPU indices.
Definition FeedEngine.h:35
~ThreadAffinity()
Utilizes all the resources.
Definition FeedEngine.h:55
TinySet< CpuIndex > CpuIndices
Alias for collection of CPU indices.
Definition FeedEngine.h:40
ThreadAffinity(const ThreadAffinity &other)
Initializes as copy of other set.
Definition FeedEngine.h:48
CpuIndices & cpus()
Collection of CPU indices.
Definition FeedEngine.h:66
const CpuIndices & cpus() const
Read-only access to index collection.
Definition FeedEngine.h:60
Class implementing set optimized for storing small number of items.
Definition TinySet.h:38
char Char
Character type alias.
Definition String.h:36
Int32 CpuIndex
Zero-based index of CPU.
Definition FeedEngine.h:31
void toStr(std::string &str, const Decimal &number)
Definition Decimal.h:502
Listener for thread-related events.
Definition FeedEngine.h:300
virtual void onFeedEngineThreadIssue(const FeedEngine &, const Char *)
Invoked if working thread experiences an issue while processing its tasks.
Definition FeedEngine.h:352
virtual void onFeedEngineThreadBegin(const FeedEngine &)
Member invoked by feed engine when a new processing thread is spawned.
Definition FeedEngine.h:308
virtual void onFeedEngineThreadEnd(const FeedEngine &)
Member is invoked by feed engine when processing thread is about to end.
Definition FeedEngine.h:320
virtual void onFeedEngineThreadIdle(const FeedEngine &, FeedEngineThreadIdle::Reason, UInt32 &)
Is called when feed engine's thread is idle.
Definition FeedEngine.h:340
Identifies reasons feed engine threads becomes idle.
Definition FeedEngine.h:276
@ DataWaitTimeout
Thread waited for incoming data using corresponding I/O operations (like 'select') and exited waiting...
Definition FeedEngine.h:282
@ Redundant
Thread entered idle state due to absence of any data and while other threads are waiting for new inco...
Definition FeedEngine.h:286