OnixS C++ CME MDP Premium Market Data Handler 5.9.0
Users' manual and 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{
45
50
56 {
57 return false;
58 }
59
62 virtual void onFeedEngineThreadIssue(const FeedEngineThreadPool&, const Char*){}
63};
64
67
70
73{
74public:
77
80 : indices_(other.indices_)
81 {
82 }
83
86
88 operator bool() const
89 {
90 return indices_.empty();
91 }
92
94 const CpuIndices& cpus() const
95 {
96 return indices_;
97 }
98
101 {
102 return indices_;
103 }
104
105private:
106 CpuIndices indices_;
107};
108
111void toStr(std::string&, const ThreadAffinity&);
112
114inline std::string toStr(const ThreadAffinity& affinity)
115{
116 std::string str;
117
118 toStr(str, affinity);
119
120 return str;
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)
const ThreadPoolSettings & pool() const
Settings related to the thread pool.
ThreadPoolSettings & pool()
Settings related to the thread pool.
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.
const ThreadAffinity & affinity() const
ThreadPoolSettings & size(UInt32 value)
Defines the number of working threads in the pool.
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 &)
virtual bool onFeedEngineThreadIdle(const FeedEngineThreadPool &)
virtual void onFeedEngineThreadIssue(const FeedEngineThreadPool &, const Char *)
virtual void onFeedEngineThreadEnd(const FeedEngineThreadPool &)