OnixS C++ CME MDP Premium Market Data Handler 5.11.1
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
73
76
79
82{
83public:
86
89 : indices_(other.indices_)
90 {
91 }
92
95
97 operator bool() const
98 {
99 return indices_.empty();
100 }
101
103 const CpuIndices& cpus() const
104 {
105 return indices_;
106 }
107
110 {
111 return indices_;
112 }
113
114private:
115 CpuIndices indices_;
116};
117
120void toStr(std::string&, const ThreadAffinity&);
121
123inline std::string toStr(const ThreadAffinity& affinity)
124{
125 std::string str;
126
127 toStr(str, affinity);
128
129 return str;
130}
131
136{
137public:
141 : affinity_()
142 , size_(1)
143 {
144 }
145
148
155 {
156 return affinity_;
157 }
158
165 {
166 return affinity_;
167 }
168
173 {
174 return size_;
175 }
176
179 {
180 size_ = value;
181 return *this;
182 }
183
184private:
185 ThreadAffinity affinity_;
186 Messaging::UInt32 size_;
187};
188
191void toStr(std::string&, const ThreadPoolSettings&);
192
194inline std::string toStr(const ThreadPoolSettings& settings)
195{
196 std::string str;
197
198 toStr(str, settings);
199
200 return str;
201}
202
206{
207public:
211 : loopBeforeIdle_(1)
212 {
213 }
214
217 {
218 return pool_;
219 }
220
223 {
224 return pool_;
225 }
226
238 {
239 return loopBeforeIdle_;
240 }
241
248 {
249 loopBeforeIdle_ = value;
250 }
251
252private:
253 ThreadPoolSettings pool_;
254 Messaging::UInt32 loopBeforeIdle_;
255};
256
260void toStr(std::string&, const FeedEngineThreadSettings&);
261
264inline std::string toStr(const FeedEngineThreadSettings& settings)
265{
266 std::string str;
267
268 toStr(str, settings);
269
270 return str;
271}
272
274
277{
278public:
282
285
286private:
287 class Workhorse;
288 Workhorse* workhorse_;
289};
290
291
294{
295public:
297 static void affinity(const ThreadAffinity&);
298 static void affinity(CpuIndex);
299};
300
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:69
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:61
#define ONIXS_CMEMDH_EXPORTED_CLASS_DECL(typeName)
Definition Bootstrap.h:50
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:73
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:163
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.
Stores a small number of unique keys in contiguous storage.
Definition TinySet.h:46
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.
TinySet< CpuIndex > CpuIndices
Alias for collection of CPU indices.
void toStr(std::string &str, BookState::Enum bookState)
Appends a string representation of a book state.
virtual void onFeedEngineThreadBegin(const FeedEngineThreadPool &)
virtual bool onFeedEngineThreadIdle(const FeedEngineThreadPool &)
virtual void onFeedEngineThreadIssue(const FeedEngineThreadPool &, const Messaging::Char *)
Invoked when a processing task or another listener callback throws an exception.
virtual void onFeedEngineThreadEnd(const FeedEngineThreadPool &)