OnixS C++ Eurex T7 Market and Reference Data (EMDI, MDI, RDI, EOBI) Handlers 18.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
22#include <string>
23#include <set>
24
29
30namespace OnixS
31{
32 namespace Eurex
33 {
34 namespace MarketData
35 {
38 {
39 public:
41 typedef UInt32 Flags;
42
45 {
46 value_.raw_ = flags;
47 }
48
51 {
52 return 0 != value_.bits_.eventsDispatched_;
53 }
54
57 {
58 value_.bits_.eventsDispatched_ = state ? 1 : 0;
59 }
60
63 {
64 return 0 != value_.bits_.ioWaited_;
65 }
66
69 {
70 value_.bits_.ioWaited_ = state ? 1 : 0;
71 }
72
75 {
76 return value_.bits_.reserved_;
77 }
78
81 {
82 value_.bits_.reserved_ = flags;
83 }
84
85 private:
86 struct Bitset
87 {
88 Flags eventsDispatched_ : 1;
89 Flags ioWaited_ : 1;
90 Flags reserved_ : 30;
91 };
92
93 union Value
94 {
95 Bitset bits_;
96 Flags raw_;
97 };
98
99 Value value_;
100 };
101
103 class ONIXS_EUREX_EMDI_API FeedEngine
104 {
105 public:
109
111 std::string info();
112
114 virtual ~FeedEngine();
115
116 protected:
117 explicit FeedEngine(void* impl);
118
119 private:
120 FeedEngine(const FeedEngine&);
121 FeedEngine& operator=(const FeedEngine&);
122
123 void* const impl_;
124 friend struct FeHelper;
125 };
126
132 inline bool process(FeedEngine& engine)
133 {
134 return engine.process().eventsDispatched();
135 }
136
138 class ONIXS_EUREX_EMDI_API SocketFeedEngine : public FeedEngine
139 {
140 public:
153 UInt32 dataWaitTime = 10, UInt32 socketBufferSize = 8 * 1024 * 1024, WatchService& watch = UtcWatch::service());
154
157 };
158
160 class ONIXS_EUREX_EMDI_API EfViFeedEngine : public FeedEngine
161 {
162 public:
175 explicit EfViFeedEngine(UInt32 receiveRingSize = 4095, WatchService& watch = NicWatch::service());
176
179 };
180
181
183 typedef size_t CpuIndex;
184
186 class ONIXS_EUREX_EMDI_API ThreadAffinity
187 {
188 typedef std::set<CpuIndex> CpuIndexes;
189
190 public:
193
196
199
201 bool empty() const;
202
204 void copyTo(CpuIndexes&) const;
205
207 bool insert(CpuIndex index);
208
210 bool erase(CpuIndex index);
211
213 void clear();
214
216 ThreadAffinity& operator = (const ThreadAffinity&);
217
219 std::string toString() const;
220
221 private:
223 CpuIndexes* indices_;
224 };
225
228 {
240 };
241
244 {
246 : threadAffinity_()
247 , spinBeforeIdleTime_(1)
248 , threadCount_(1)
249 {
250 }
251
260 {
261 return threadAffinity_;
262 }
263
272 {
273 return threadAffinity_;
274 }
275
280 {
281 return threadCount_;
282 }
283
285 void threadCount(UInt32 value)
286 {
287 threadCount_ = value;
288 }
289
299 {
300 return spinBeforeIdleTime_;
301 }
302
305 {
306 spinBeforeIdleTime_ = value;
307 }
308
309 private:
310 ThreadAffinity threadAffinity_;
311 UInt32 spinBeforeIdleTime_;
312 UInt32 threadCount_;
313 };
314
315 class ONIXS_EUREX_EMDI_API FeedEngineThreadPool;
316
347
349 class ONIXS_EUREX_EMDI_API FeedEngineThreadPool
350 {
351 public:
354
356
358
359 private:
362
363 const FeedEngineThreadPoolSettings settings_;
364 class FeedEngineThreadPoolImpl;
365 FeedEngineThreadPoolImpl* impl_;
366 };
367
369 class ONIXS_EUREX_EMDI_API ThisThread
370 {
371 public:
373 static void affinity(const ThreadAffinity&);
374 static void affinity(CpuIndex);
375 };
376 }
377 }
378}
#define ONIXS_EUREX_EMDI_OVERRIDE
Definition Compiler.h:134
#define ONIXS_EUREX_EMDI_NULLPTR
Definition Compiler.h:143
#define ONIXS_EUREX_EMDI_NOEXCEPT
Definition Compiler.h:130
~EfViFeedEngine() ONIXS_EUREX_EMDI_OVERRIDE
EfViFeedEngine(UInt32 receiveRingSize=4095, WatchService &watch=NicWatch::service())
A pool of threads executing feed engine tasks.
Definition FeedEngine.h:350
FeedEngineThreadPool(const FeedEngineThreadPoolSettings &, FeedEngine *, FeedEngineThreadPoolListener *=ONIXS_EUREX_EMDI_NULLPTR)
const FeedEngineThreadPoolSettings settings() const
The Feed Engine machinery.
Definition FeedEngine.h:104
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:38
bool ioWaited() const ONIXS_EUREX_EMDI_NOEXCEPT
Indicates whether processing had to sleep in kernel while checking data availability.
Definition FeedEngine.h:62
void eventsDispatched(bool state) ONIXS_EUREX_EMDI_NOEXCEPT
Indicates whether feed-related events like data reception or absence have been dispatched.
Definition FeedEngine.h:56
Flags reserved() const ONIXS_EUREX_EMDI_NOEXCEPT
Reserved (unused) flags.
Definition FeedEngine.h:74
bool eventsDispatched() const ONIXS_EUREX_EMDI_NOEXCEPT
Indicates whether feed-related events like data reception or absence have been dispatched.
Definition FeedEngine.h:50
NetFeedEngineProcessResult(UInt32 flags) ONIXS_EUREX_EMDI_NOEXCEPT
Definition FeedEngine.h:44
void reserved(Flags flags) ONIXS_EUREX_EMDI_NOEXCEPT
Reserved (unused) flags.
Definition FeedEngine.h:80
void ioWaited(bool state) ONIXS_EUREX_EMDI_NOEXCEPT
Indicates whether processing had to sleep in kernel while checking data availability.
Definition FeedEngine.h:68
UInt32 Flags
Aliases integral type whose bits are used to indicate flag presence.
Definition FeedEngine.h:41
static NicWatch & service()
Returns watch service.
~SocketFeedEngine() ONIXS_EUREX_EMDI_OVERRIDE
SocketFeedEngine(UInt32 dataWaitTime=10, UInt32 socketBufferSize=8 *1024 *1024, WatchService &watch=UtcWatch::service())
Current thread related tasks.
Definition FeedEngine.h:370
static void affinity(const ThreadAffinity &)
Sets the processor affinity mask for the current thread.
Represents set of CPU indices.
Definition FeedEngine.h:187
ThreadAffinity()
Initializes empty set.
std::string toString() const
Returns the string representation.
ThreadAffinity(const ThreadAffinity &)
Initializes as copy of other set.
bool empty() const
Indicates whether is empty.
~ThreadAffinity()
Utilizes all the resources.
bool erase(CpuIndex index)
Removes CPU index from the set.
bool insert(CpuIndex index)
Adds CPU index into set.
void copyTo(CpuIndexes &) const
Copies set into another set.
static UtcWatch & service()
Returns watch service.
size_t CpuIndex
Zero-based index of CPU.
Definition FeedEngine.h:183
unsigned int UInt32
Definition Numeric.h:41
bool process(FeedEngine &engine)
Definition FeedEngine.h:132
Identifies reasons feed engine threads becomes idle.
Definition FeedEngine.h:228
virtual void onFeedEngineThreadBegin(const FeedEngineThreadPool &)
Definition FeedEngine.h:329
virtual void onFeedEngineThreadIdle(const FeedEngineThreadPool &, FeedEngineThreadIdle::Reason, UInt32 &)
Definition FeedEngine.h:342
virtual void onFeedEngineThreadEnd(const FeedEngineThreadPool &)
Definition FeedEngine.h:336
void threadCount(UInt32 value)
Sets threadsCount.
Definition FeedEngine.h:285
void spinBeforeIdleTime(UInt32 value)
Sets redundancySpinTime.
Definition FeedEngine.h:304