OnixS C++ SGX Titan ITCH Market Data Handler  1.2.2
API documentation
FeedEngineSettings.cpp
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 
22 
23 #include "Formatting.h"
24 #include "Formatting.Helpers.h"
25 
26 #include <sstream>
27 
28 #include "NamespaceHelper.h"
29 
30 using namespace std;
31 
32 ONIXS_HANDLER_NAMESPACE_BEGIN
33 
34 ThreadAffinity::ThreadAffinity()
35 : indices_(new CpuIndexes())
36 {
37 }
38 
40  : indices_(new CpuIndexes())
41 {
42  *indices_ = *other.indices_;
43 }
44 
46 {
47  delete indices_;
48 }
49 
51 {
52  return indices_->empty();
53 }
54 
55 void ThreadAffinity::copyTo(CpuIndexes& indices) const
56 {
57  indices.insert(indices_->begin(), indices_->end());
58 }
59 
61 {
62  return indices_->insert(index).second;
63 }
64 
66 {
67  return indices_->erase(index);
68 }
69 
71 {
72  indices_->clear();
73 }
74 
76 {
77  *indices_ = *other.indices_;
78 
79  return *this;
80 }
81 
82 /// Returns the string representation.
83 std::string ThreadAffinity::toString() const
84 {
85  Util::TextBuilder builder;
86  builder << Util::JoinWrapper<CpuIndexes>(*indices_, ",");
87  return builder.toString();
88 }
89 
91  : threadAffinity_()
92  , threadCount_(1)
93  , dataWaitTime_(10)
94  , spinBeforeIdleTime_(1)
95  , socketBufferSize_(8 * 1024 * 1024)
96 {
97 }
98 
100 {
101 }
102 
104 {
105  ostringstream out;
106  out << *this;
107  return out.str();
108 }
109 
110 std::ostream & operator << (std::ostream & stream, const FeedEngineSettings & settings)
111 {
112  stream << "FeedEngineSettings [dataWaitTime=" << settings.dataWaitTime()
113  << ", " << "threadAffinity=" << settings.threadAffinity().toString()
114  << ", " << "threadCount=" << settings.threadCount()
115  << ", " << "spinBeforeIdleTime=" << settings.spinBeforeIdleTime()
116  << ", " << "udpSocketBufferSize=" << settings.socketBufferSize()
117  << "]";
118 
119  return stream;
120 }
121 
122 
123 ONIXS_HANDLER_NAMESPACE_END
FeedEngineSettings()
Initializes options with default values.
ThreadAffinity & operator=(const ThreadAffinity &)
Re-initializes instance as copy of other set.
bool erase(CpuIndex index)
Removes CPU index from the set.
Represents set of CPU indices.
Definition: FeedEngine.h:36
STL namespace.
size_t CpuIndex
Zero-based index of CPU.
Definition: FeedEngine.h:33
void copyTo(CpuIndexes &) const
Copies set into another set.
const ThreadAffinity & threadAffinity() const
Definition: FeedEngine.h:105
std::string toString() const
Returns the string representation.
ONIXS_SGXTITAN_ITCH_API std::ostream & operator<<(std::ostream &stream, const ServiceDescriptor &descriptor)
Collection of settings affecting Feed Engine behavior.
Definition: FeedEngine.h:78
std::string toString() const
Returns the string representation.
bool insert(CpuIndex index)
Adds CPU index into set.
bool empty() const
Indicates whether is empty.