OnixS C++ FMX UST BIMP Market Data Handler 1.2.0
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 FmxUST
32 {
33 namespace MarketData
34 {
35 namespace Bimp
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_FMXUST_BIMP_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_FMXUST_BIMP_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_FMXUST_BIMP_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
235 UInt32 threadCount() const
236 {
237 return threadCount_;
238 }
239
241 void threadCount(UInt32 value)
242 {
243 threadCount_ = value;
244 }
245
254 UInt32 spinBeforeIdleTime() const
255 {
256 return spinBeforeIdleTime_;
257 }
258
260 void spinBeforeIdleTime(UInt32 value)
261 {
262 spinBeforeIdleTime_ = value;
263 }
264
265 private:
266 ThreadAffinity threadAffinity_;
267 UInt32 spinBeforeIdleTime_;
268 UInt32 threadCount_;
269 };
270
271 class ONIXS_FMXUST_BIMP_API FeedEngineThreadPool;
272
278 struct ONIXS_FMXUST_BIMP_API FeedEngineThreadPoolListener
279 {
286
293
299
302 };
303
305 class ONIXS_FMXUST_BIMP_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_FMXUST_BIMP_API ThisThread
326 {
327 public:
329 static void affinity(const ThreadAffinity&);
330 static void affinity(CpuIndex);
331 };
332 }
333 }
334 }
335}
#define ONIXS_FMXUST_BIMP_NOTHROW
Definition Compiler.h:108
#define ONIXS_FMXUST_BIMP_OVERRIDE
Definition Compiler.h:113
#define ONIXS_FMXUST_BIMP_NULLPTR
Definition Compiler.h:122
EfViFeedEngine(UInt32 receiveRingSize=4095, WatchService &watch=NicWatch::service())
~EfViFeedEngine() ONIXS_FMXUST_BIMP_OVERRIDE
A pool of threads executing feed engine tasks.
Definition FeedEngine.h:306
FeedEngineThreadPool(const FeedEngineThreadPoolSettings &, FeedEngine *, FeedEngineThreadPoolListener *=ONIXS_FMXUST_BIMP_NULLPTR)
const FeedEngineThreadPoolSettings settings() const
std::string info()
Provides information about the actual implementation of the feed engine.
NetFeedEngineProcessResult process()
Designed to reflect various aspects of feed engine processing flow.
Definition FeedEngine.h:39
NetFeedEngineProcessResult(UInt32 flags) ONIXS_FMXUST_BIMP_NOTHROW
Definition FeedEngine.h:45
bool ioWaited() const ONIXS_FMXUST_BIMP_NOTHROW
Indicates whether processing had to sleep in kernel while checking data availability.
Definition FeedEngine.h:63
void eventsDispatched(bool state) ONIXS_FMXUST_BIMP_NOTHROW
Indicates whether feed-related events like data reception or absence have been dispatched.
Definition FeedEngine.h:57
void ioWaited(bool state) ONIXS_FMXUST_BIMP_NOTHROW
Indicates whether processing had to sleep in kernel while checking data availability.
Definition FeedEngine.h:69
Flags reserved() const ONIXS_FMXUST_BIMP_NOTHROW
Reserved (unused) flags.
Definition FeedEngine.h:75
void reserved(Flags flags) ONIXS_FMXUST_BIMP_NOTHROW
Reserved (unused) flags.
Definition FeedEngine.h:81
bool eventsDispatched() const ONIXS_FMXUST_BIMP_NOTHROW
Indicates whether feed-related events like data reception or absence have been dispatched.
Definition FeedEngine.h:51
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())
~SocketFeedEngine() ONIXS_FMXUST_BIMP_OVERRIDE
Current thread related tasks.
Definition FeedEngine.h:326
static void affinity(const ThreadAffinity &)
Sets the processor affinity mask for the current thread.
Represents set of CPU indices.
Definition Defines.h:111
static UtcWatch & service()
Returns watch service.
size_t CpuIndex
Zero-based index of CPU.
Definition Defines.h:107
bool process(FeedEngine &engine)
Definition FeedEngine.h:133
Identifies reasons feed engine threads becomes idle.
Definition FeedEngine.h:184
virtual void onFeedEngineThreadBegin(const FeedEngineThreadPool &)
Definition FeedEngine.h:285
virtual void onFeedEngineThreadIdle(const FeedEngineThreadPool &, FeedEngineThreadIdle::Reason, UInt32 &)
Definition FeedEngine.h:298
virtual void onFeedEngineThreadEnd(const FeedEngineThreadPool &)
Definition FeedEngine.h:292
void spinBeforeIdleTime(UInt32 value)
Sets redundancySpinTime.
Definition FeedEngine.h:260