OnixS C++ CME MDP Premium Market Data Handler 5.9.0
API Documentation
Loading...
Searching...
No Matches
FeedEngineThreadPool.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 <vector>
24
28
30
31ONIXS_CMEMDH_EXPORTED_CLASS_DECL(FeedEngineThreadPool);
32
39{
44
49
54 {
55 return false;
56 }
57
60 virtual void onFeedEngineThreadIssue(const FeedEngineThreadPool&, const Char*){}
61};
62
65
68
71{
72public:
75
78 : indices_(other.indices_)
79 {
80 }
81
84
86 operator bool() const
87 {
88 return indices_.empty();
89 }
90
92 const CpuIndices& cpus() const
93 {
94 return indices_;
95 }
96
99 {
100 return indices_;
101 }
102
103private:
104 CpuIndices indices_;
105};
106
109void toStr(std::string&, const ThreadAffinity&);
110
112inline std::string toStr(const ThreadAffinity& affinity)
113{
114 std::string str;
115
116 toStr(str, affinity);
117
118 return str;
119}
120
121//
122
127{
128public:
132 : affinity_()
133 , size_(1)
134 {
135 }
136
139
146 {
147 return affinity_;
148 }
149
156 {
157 return affinity_;
158 }
159
163 UInt32 size() const
164 {
165 return size_;
166 }
167
170 {
171 size_ = value;
172 return *this;
173 }
174
175private:
176 ThreadAffinity affinity_;
177 UInt32 size_;
178};
179
182void toStr(std::string&, const ThreadPoolSettings&);
183
185inline std::string toStr(const ThreadPoolSettings& settings)
186{
187 std::string str;
188
189 toStr(str, settings);
190
191 return str;
192}
193
197{
198public:
202 : loopBeforeIdle_(1)
203 {
204 }
205
208 {
209 return pool_;
210 }
211
214 {
215 return pool_;
216 }
217
229 {
230 return loopBeforeIdle_;
231 }
232
239 {
240 loopBeforeIdle_ = value;
241 }
242
243private:
244 ThreadPoolSettings pool_;
245 UInt32 loopBeforeIdle_;
246};
247
251void toStr(std::string&, const FeedEngineThreadSettings&);
252
255inline std::string toStr(const FeedEngineThreadSettings& settings)
256{
257 std::string str;
258
259 toStr(str, settings);
260
261 return str;
262}
263
265
268{
269public:
273
276
277private:
278 class Workhorse;
279 Workhorse* workhorse_;
280};
281
282
285{
286public:
288 static void affinity(const ThreadAffinity&);
289 static void affinity(CpuIndex);
290};
291
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:67
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:46
#define ONIXS_CMEMDH_EXPORTED_CLASS_DECL(typeName)
Definition Bootstrap.h:35
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:68
#define ONIXS_CMEMDH_NULLPTR
Definition Compiler.h:178
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:171
A pool of threads executing feed engine tasks.
~FeedEngineThreadPool()
Stops all tasks and destructs the working threads.
FeedEngineThreadPool(NetFeedEngine &, const FeedEngineThreadSettings &, FeedEngineThreadPoolListener *=nullptr)
Initializes working threads and spawns feed engine process() routine invocation.
The collection of parameters affecting behavior of a Feed Engine thread pool.
const ThreadPoolSettings & pool() const
Settings related to the thread pool.
ThreadPoolSettings & pool()
Settings related to the thread pool.
void loopBeforeIdle(UInt32 value)
Updates amount of cycles a working thread keeps cycling before entering the idle state if no useful a...
UInt32 loopBeforeIdle() const
Defines amount of cycles a working thread keeps cycling before entering the idle state if no useful a...
FeedEngineThreadSettings()
Assigns the default values for the given instance of the thread pool settings.
Abstraction for the Feed Engine machinery.
Definition FeedEngine.h:102
Current thread related tasks.
static void affinity(CpuIndex)
static void affinity(const ThreadAffinity &)
Sets the processor affinity mask for the current thread.
Represents a set of CPU indices.
ThreadAffinity()
Initializes the empty set.
~ThreadAffinity()
Utilizes internal resources.
ThreadAffinity(const ThreadAffinity &other)
Initializes as a copy of the other set.
CpuIndices & cpus()
Collection of the CPU indices.
const CpuIndices & cpus() const
Read-only access to the indices.
The collection of parameters affecting behavior of a thread pool.
UInt32 size() const
Number of working threads in the pool.
const ThreadAffinity & affinity() const
Defines set of CPUs allowed for each working thread to be executed on while running tasks.
ThreadAffinity & affinity()
Defines set of CPUs allowed for each working thread to be executed on while running tasks.
ThreadPoolSettings & size(UInt32 value)
Defines the number of working threads in the pool.
ThreadPoolSettings()
Assigns the default values for the given instance of the thread pool settings.
Class implementing set optimized for storing small number of items.
Definition TinySet.h:35
Int32 Int32
int32.
Definition Fields.h:60
char Char
Character type alias.
Definition String.h:36
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
UInt32 UInt32
uInt32.
Definition Fields.h:202
TinySet< CpuIndex > CpuIndices
Alias for collection of CPU indices.
Int32 CpuIndex
Zero-based index of CPU.
virtual void onFeedEngineThreadBegin(const FeedEngineThreadPool &)
Invoked by the thread before entering the processing loop.
virtual bool onFeedEngineThreadIdle(const FeedEngineThreadPool &)
Invoked when the thread is idle.
virtual void onFeedEngineThreadIssue(const FeedEngineThreadPool &, const Char *)
Invoked when the thread experiences an issue while processing its tasks.
virtual void onFeedEngineThreadEnd(const FeedEngineThreadPool &)
Invoked by the thread when it is about to end.