OnixS BME SENAF Handler C++ library  2.2.1
API documentation
ThreadAffinity.h
Go to the documentation of this file.
1 /*
2  * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3  *
4  * This software owned by Onix Solutions Limited [OnixS] and is protected by
5  * copyright law and international copyright treaties.
6  *
7  * Access to and use of the software is governed by the terms of the applicable
8  * ONIXS Software Services Agreement (the Agreement) and Customer end user
9  * license agreements granting a non-assignable, non-transferable and
10  * non-exclusive license to use the software for it's own data processing
11  * purposes under the terms defined in the Agreement.
12  *
13  * Except as otherwise granted within the terms of the Agreement, copying or
14  * reproduction of any part of this source code or associated reference material
15  * to any other location for further reproduction or redistribution, and any
16  * amendments to this copyright notice, are expressly prohibited.
17  *
18  * Any reproduction or redistribution for sale or hiring of the Software not in
19  * accordance with the terms of the Agreement is a violation of copyright law.
20  */
21 
22 #pragma once
23 
24 #include <OnixS/Senaf/MarketData/Export.h>
25 
26 #include <set>
27 #include <string>
28 
29 namespace OnixS { namespace Senaf { namespace MarketData {
30 
31 /// Zero-based index of CPU.
32 typedef int CpuIndex;
33 
34 /// Represents set of CPU indices.
35 class ONIXS_BME_SENAF_EXPORT ThreadAffinity
36 {
37 public:
38  /// Initializes empty set.
40 
41  /// Initializes as copy of other set.
43 
44  /// Utilizes all the resources.
45  ~ThreadAffinity();
46 
47  /// Indicates whether is empty.
48  bool empty() const;
49 
50  /// Copies set into another set.
51  void copyTo(std::set<CpuIndex>&) const;
52 
53  /// Adds CPU index into set.
54  bool insert(CpuIndex index);
55 
56  /// Removes CPU index from the set.
57  bool erase(CpuIndex index);
58 
59  /// Makes set empty.
60  void clear();
61 
62  /// Re-initializes instance as copy of other set.
63  ThreadAffinity& operator=(const ThreadAffinity&);
64 
65  /// Returns textual presentation.
66  std::string toString() const;
67 
68  /// Serializes indices into text.
69  void toString(std::string&) const;
70 
71  /// Returns thread affinity of given string presentation.
72  static ThreadAffinity deserialize(const std::string&);
73 
74 private:
75  /// System index.
76  std::set<CpuIndex>* indices_;
77 };
78 
79 inline std::string ThreadAffinity::toString() const
80 {
81  std::string str;
82  toString(str);
83  return str;
84 }
85 
86 }}} // namespace OnixS::Senaf::MarketData
int CpuIndex
Zero-based index of CPU.
std::string toString() const
Returns textual presentation.
Represents set of CPU indices.