OnixS C++ CME MDP Premium Market Data Handler 5.10.2
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
29#include <OnixS/CME/MDH/Auxiliary/DeprecatedHeaderWarnings.Disable.h>
31#include <OnixS/CME/MDH/Auxiliary/DeprecatedHeaderWarnings.Restore.h>
32
34
35ONIXS_CMEMDH_EXPORTED_CLASS_DECL(FeedEngineThreadPool);
36
68
71
74
77{
78public:
81
84 : indices_(other.indices_)
85 {
86 }
87
90
92 operator bool() const
93 {
94 return indices_.empty();
95 }
96
98 const CpuIndices& cpus() const
99 {
100 return indices_;
101 }
102
105 {
106 return indices_;
107 }
108
109private:
110 CpuIndices indices_;
111};
112
115void toStr(std::string&, const ThreadAffinity&);
116
118inline std::string toStr(const ThreadAffinity& affinity)
119{
120 std::string str;
121
122 toStr(str, affinity);
123
124 return str;
125}
126
131{
132public:
136 : affinity_()
137 , size_(1)
138 {
139 }
140
143
150 {
151 return affinity_;
152 }
153
160 {
161 return affinity_;
162 }
163
168 {
169 return size_;
170 }
171
174 {
175 size_ = value;
176 return *this;
177 }
178
179private:
180 ThreadAffinity affinity_;
181 Messaging::UInt32 size_;
182};
183
186void toStr(std::string&, const ThreadPoolSettings&);
187
189inline std::string toStr(const ThreadPoolSettings& settings)
190{
191 std::string str;
192
193 toStr(str, settings);
194
195 return str;
196}
197
201{
202public:
206 : loopBeforeIdle_(1)
207 {
208 }
209
212 {
213 return pool_;
214 }
215
218 {
219 return pool_;
220 }
221
233 {
234 return loopBeforeIdle_;
235 }
236
243 {
244 loopBeforeIdle_ = value;
245 }
246
247private:
248 ThreadPoolSettings pool_;
249 Messaging::UInt32 loopBeforeIdle_;
250};
251
255void toStr(std::string&, const FeedEngineThreadSettings&);
256
259inline std::string toStr(const FeedEngineThreadSettings& settings)
260{
261 std::string str;
262
263 toStr(str, settings);
264
265 return str;
266}
267
269
272{
273public:
277
280
281private:
282 class Workhorse;
283 Workhorse* workhorse_;
284};
285
286
289{
290public:
292 static void affinity(const ThreadAffinity&);
293 static void affinity(CpuIndex);
294};
295
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:54
#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:55
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:148
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(Messaging::UInt32 value)
Defines the number of working threads in the pool.
std::uint32_t UInt32
uInt32.
Definition Integral.h:35
char Char
Character type alias.
Definition String.h:30
std::int32_t Int32
int32.
Definition Integral.h:34
Messaging::Int32 CpuIndex
Zero-based index of CPU.
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.
TinySet< CpuIndex > CpuIndices
Alias for collection of CPU indices.
virtual void onFeedEngineThreadBegin(const FeedEngineThreadPool &)
virtual bool onFeedEngineThreadIdle(const FeedEngineThreadPool &)
virtual void onFeedEngineThreadIssue(const FeedEngineThreadPool &, const Messaging::Char *)
virtual void onFeedEngineThreadEnd(const FeedEngineThreadPool &)