OnixS C++ Euronext Optiq MDG Handler 1.3.3
API documentation
Loading...
Searching...
No Matches
FeedEngine.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19
20#pragma once
21
26
27#include <string>
28
29namespace OnixS
30{
31 namespace Euronext
32 {
33 namespace MarketData
34 {
35 namespace OptiqMdg
36 {
39 {
40 public:
42 typedef UInt32 Flags;
43
46 {
47 value_.raw_ = flags;
48 }
49
52 {
53 return 0 != value_.bits_.eventsDispatched_;
54 }
55
58 {
59 value_.bits_.eventsDispatched_ = state ? 1 : 0;
60 }
61
64 {
65 return 0 != value_.bits_.ioWaited_;
66 }
67
70 {
71 value_.bits_.ioWaited_ = state ? 1 : 0;
72 }
73
76 {
77 return value_.bits_.reserved_;
78 }
79
82 {
83 value_.bits_.reserved_ = flags;
84 }
85
86 private:
87 struct Bitset
88 {
89 Flags eventsDispatched_ : 1;
90 Flags ioWaited_ : 1;
91 Flags reserved_ : 30;
92 };
93
94 union Value
95 {
96 Bitset bits_;
97 Flags raw_;
98 };
99
100 Value value_;
101 };
102
104 class ONIXS_EURONEXT_OPTIQMDG_API FeedEngine
105 {
106 public:
110
112 std::string info();
113
115 virtual ~FeedEngine();
116
117 protected:
118 explicit FeedEngine(void* impl);
119
120 private:
121 FeedEngine(const FeedEngine&);
122 FeedEngine& operator=(const FeedEngine&);
123
124 void* const impl_;
125 friend struct FeHelper;
126 };
127
133 inline bool process(FeedEngine& engine)
134 {
135 return engine.process().eventsDispatched();
136 }
137
139 class ONIXS_EURONEXT_OPTIQMDG_API SocketFeedEngine : public FeedEngine
140 {
141 public:
154 UInt32 dataWaitTime = 10, UInt32 socketBufferSize = 8 * 1024 * 1024, WatchService& watch = UtcWatch::service());
155
158 };
159
161 class ONIXS_EURONEXT_OPTIQMDG_API EfViFeedEngine : public FeedEngine
162 {
163 public:
176 explicit EfViFeedEngine(UInt32 receiveRingSize = 4095, WatchService& watch = NicWatch::service());
177
180 };
181
184 {
196 };
197
200 {
202 : threadAffinity_()
203 , spinBeforeIdleTime_(1)
204 , threadCount_(1)
205 {
206 }
207
216 {
217 return threadAffinity_;
218 }
219
228 {
229 return threadAffinity_;
230 }
231
236 {
237 return threadCount_;
238 }
239
241 void threadCount(UInt32 value)
242 {
243 threadCount_ = value;
244 }
245
255 {
256 return spinBeforeIdleTime_;
257 }
258
261 {
262 spinBeforeIdleTime_ = value;
263 }
264
265 private:
266 ThreadAffinity threadAffinity_;
267 UInt32 spinBeforeIdleTime_;
268 UInt32 threadCount_;
269 };
270
271 class ONIXS_EURONEXT_OPTIQMDG_API FeedEngineThreadPool;
272
278 struct ONIXS_EURONEXT_OPTIQMDG_API FeedEngineThreadPoolListener
279 {
286
293
299
302 };
303
305 class ONIXS_EURONEXT_OPTIQMDG_API FeedEngineThreadPool
306 {
307 public:
310
312
314
315 private:
318
319 const FeedEngineThreadPoolSettings settings_;
320 class FeedEngineThreadPoolImpl;
321 FeedEngineThreadPoolImpl* impl_;
322 };
323
325 class ONIXS_EURONEXT_OPTIQMDG_API ThisThread
326 {
327 public:
329 static void affinity(const ThreadAffinity&);
330 static void affinity(CpuIndex);
331 };
332 }
333 }
334 }
335}
#define ONIXS_EURONEXT_OPTIQMDG_NOTHROW
Definition Compiler.h:186
#define ONIXS_EURONEXT_OPTIQMDG_OVERRIDE
Definition Compiler.h:190
#define ONIXS_EURONEXT_OPTIQMDG_NULLPTR
Definition Compiler.h:192
EfViFeedEngine(UInt32 receiveRingSize=4095, WatchService &watch=NicWatch::service())
Constructor.
A pool of threads executing feed engine tasks.
Definition FeedEngine.h:306
const FeedEngineThreadPoolSettings settings() const
FeedEngineThreadPool(const FeedEngineThreadPoolSettings &, FeedEngine *, FeedEngineThreadPoolListener *=nullptr)
std::string info()
Provides information about the actual implementation of the feed engine.
NetFeedEngineProcessResult process()
Carries out pending actions like data retrieval and event dispatching.
Designed to reflect various aspects of feed engine processing flow.
Definition FeedEngine.h:39
void reserved(Flags flags) noexcept
Reserved (unused) flags.
Definition FeedEngine.h:81
void ioWaited(bool state) noexcept
Indicates whether processing had to sleep in kernel while checking data availability.
Definition FeedEngine.h:69
Flags reserved() const noexcept
Reserved (unused) flags.
Definition FeedEngine.h:75
bool ioWaited() const noexcept
Indicates whether processing had to sleep in kernel while checking data availability.
Definition FeedEngine.h:63
bool eventsDispatched() const noexcept
Indicates whether feed-related events like data reception or absence have been dispatched.
Definition FeedEngine.h:51
void eventsDispatched(bool state) noexcept
Indicates whether feed-related events like data reception or absence have been dispatched.
Definition FeedEngine.h:57
UInt32 Flags
Aliases integral type whose bits are used to indicate flag presence.
Definition FeedEngine.h:42
static NicWatch & service()
Returns watch service.
SocketFeedEngine(UInt32 dataWaitTime=10, UInt32 socketBufferSize=8 *1024 *1024, WatchService &watch=UtcWatch::service())
Constructor.
static void affinity(const ThreadAffinity &)
Sets the processor affinity mask for the current thread.
static UtcWatch & service()
Returns watch service.
size_t CpuIndex
Zero-based index of CPU.
Definition Defines.h:83
bool process(FeedEngine &engine)
Carries out pending actions like data retrieval and event dispatching.
Definition FeedEngine.h:133
Identifies reasons feed engine threads becomes idle.
Definition FeedEngine.h:184
@ DataWaitTimeout
Thread waited for incoming data using corresponding I/O operations (like 'select') and exited waiting...
Definition FeedEngine.h:190
@ Redundant
Thread entered idle state due to absence of any data and while other threads are waiting for new inco...
Definition FeedEngine.h:194
virtual void onFeedEngineThreadBegin(const FeedEngineThreadPool &)
Member invoked by feed engine when a new processing thread is spawned.
Definition FeedEngine.h:285
virtual void onFeedEngineThreadIdle(const FeedEngineThreadPool &, FeedEngineThreadIdle::Reason, UInt32 &)
Is called when feed engine's thread is idle.
Definition FeedEngine.h:298
virtual void onFeedEngineThreadEnd(const FeedEngineThreadPool &)
Member is invoked by feed engine when processing thread is about to end.
Definition FeedEngine.h:292
UInt32 spinBeforeIdleTime() const
Defines amount of time Feed Engine keeps cycling before going to sleep when no useful activity can be...
Definition FeedEngine.h:254
ThreadAffinity & threadAffinity()
Defines set of CPUs allowed for each working thread to be executed on while processing market data by...
Definition FeedEngine.h:227
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:215
void spinBeforeIdleTime(UInt32 value)
Sets redundancySpinTime.
Definition FeedEngine.h:260
UInt32 threadCount() const
Number of working threads to be used by feed engine.
Definition FeedEngine.h:235