QuantumLibrary
quantum_queue_statistics_impl.h
1 /*
2 ** Copyright 2018 Bloomberg Finance L.P.
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16 //NOTE: DO NOT INCLUDE DIRECTLY
17 
18 //##############################################################################################
19 //#################################### IMPLEMENTATIONS #########################################
20 //##############################################################################################
21 
22 namespace Bloomberg {
23 namespace quantum {
24 
25 inline
27 {
28  reset();
29 }
30 
31 inline
33 {
34  _numElements = 0;
35  _errorCount = 0;
36  _sharedQueueErrorCount = 0;
37  _completedCount = 0;
38  _sharedQueueCompletedCount = 0;
39  _postedCount = 0;
40  _highPriorityCount = 0;
41 }
42 
43 inline
45 {
46  return _numElements;
47 }
48 
49 inline
51 {
52  ++_numElements;
53 }
54 
55 inline
57 {
58  --_numElements;
59 }
60 
61 inline
63 {
64  return _errorCount;
65 }
66 
67 inline
69 {
70  ++_errorCount;
71 }
72 
73 inline
75 {
76  return _sharedQueueErrorCount;
77 }
78 
79 inline
81 {
82  ++_sharedQueueErrorCount;
83 }
84 
85 inline
87 {
88  return _completedCount;
89 }
90 
91 inline
93 {
94  ++_completedCount;
95 }
96 
97 inline
99 {
100  return _sharedQueueCompletedCount;
101 }
102 
103 inline
105 {
106  ++_sharedQueueCompletedCount;
107 }
108 
109 inline
111 {
112  return _postedCount;
113 }
114 
115 inline
117 {
118  ++_postedCount;
119 }
120 
121 inline
123 {
124  return _highPriorityCount;
125 }
126 
127 inline
129 {
130  ++_highPriorityCount;
131 }
132 
133 inline
134 void QueueStatistics::print(std::ostream& out) const
135 {
136  out << "Num elemetns: " << _numElements << std::endl;
137  out << "Num queued: " << _errorCount << std::endl;
138  out << "Num completed: " << _completedCount << std::endl;
139  out << "Num shared completed: " << _sharedQueueCompletedCount << std::endl;
140  out << "Num errors: " << _errorCount << std::endl;
141  out << "Num shared errors: " << _sharedQueueErrorCount << std::endl;
142  out << "Num high priority count: " << _highPriorityCount << std::endl;
143 }
144 
145 inline
147 {
148  _numElements += rhs.numElements();
149  _errorCount += rhs.errorCount();
150  _sharedQueueErrorCount += rhs.sharedQueueErrorCount();
151  _completedCount += rhs.completedCount();
152  _sharedQueueCompletedCount += rhs.sharedQueueCompletedCount();
153  _postedCount += rhs.postedCount();
154  _highPriorityCount += rhs.highPriorityCount();
155  return *this;
156 }
157 
158 inline
160  const IQueueStatistics& rhs)
161 {
162  lhs += rhs;
163  return lhs;
164 }
165 
166 inline
167 std::ostream& operator<<(std::ostream& out, const IQueueStatistics& stats)
168 {
169  stats.print(out);
170  return out;
171 }
172 
173 }}
virtual size_t highPriorityCount() const =0
Count of all coroutine and IO tasks which were posted on this queue at higher priority.
Definition: quantum_buffer_impl.h:22
size_t sharedQueueCompletedCount() const final
Count of all IO tasks which were dequeued from the shared queue and completed successfully.
Definition: quantum_queue_statistics_impl.h:98
QueueStatistics()
Definition: quantum_queue_statistics_impl.h:26
void reset() final
Reset all the counters to 0.
Definition: quantum_queue_statistics_impl.h:32
void incHighPriorityCount() final
Increment this counter.
Definition: quantum_queue_statistics_impl.h:128
size_t postedCount() const final
Count of all coroutine and IO tasks which were posted on this queue.
Definition: quantum_queue_statistics_impl.h:110
virtual size_t numElements() const =0
Gets the current size of the queue.
virtual size_t errorCount() const =0
Count of all coroutine and IO task execution errors on this queue.
void incSharedQueueErrorCount() final
Increment this counter.
Definition: quantum_queue_statistics_impl.h:80
void incPostedCount() final
Increment this counter.
Definition: quantum_queue_statistics_impl.h:116
virtual void print(std::ostream &out) const =0
Print to std::cout the value of all internal counters.
Provides various counters related to queues and task execution.
Definition: quantum_queue_statistics.h:30
size_t errorCount() const final
Count of all coroutine and IO task execution errors on this queue.
Definition: quantum_queue_statistics_impl.h:62
virtual size_t completedCount() const =0
Count of all coroutine and IO tasks which completed successfully.
void incSharedQueueCompletedCount() final
Increment this counter.
Definition: quantum_queue_statistics_impl.h:104
virtual size_t postedCount() const =0
Count of all coroutine and IO tasks which were posted on this queue.
virtual size_t sharedQueueErrorCount() const =0
Count of all IO tasks which were dequeued from the shared queue and failed.
size_t sharedQueueErrorCount() const final
Count of all IO tasks which were dequeued from the shared queue and failed.
Definition: quantum_queue_statistics_impl.h:74
void incCompletedCount() final
Increment this counter.
Definition: quantum_queue_statistics_impl.h:92
size_t highPriorityCount() const final
Count of all coroutine and IO tasks which were posted on this queue at higher priority.
Definition: quantum_queue_statistics_impl.h:122
std::ostream & operator<<(std::ostream &out, const IQueueStatistics &stats)
Overloads stream operator for IQueueStatistics object.
Definition: quantum_queue_statistics_impl.h:167
void incErrorCount() final
Increment this counter.
Definition: quantum_queue_statistics_impl.h:68
size_t completedCount() const final
Count of all coroutine and IO tasks which completed successfully.
Definition: quantum_queue_statistics_impl.h:86
QueueStatistics & operator+=(const IQueueStatistics &rhs)
Definition: quantum_queue_statistics_impl.h:146
QueueStatistics operator+(QueueStatistics lhs, const IQueueStatistics &rhs)
Definition: quantum_queue_statistics_impl.h:159
Interface to access and manipulate a QueueStatistics object.
Definition: quantum_iqueue_statistics.h:29
virtual size_t sharedQueueCompletedCount() const =0
Count of all IO tasks which were dequeued from the shared queue and completed successfully.
size_t numElements() const final
Gets the current size of the queue.
Definition: quantum_queue_statistics_impl.h:44
void incNumElements() final
Increment this counter.
Definition: quantum_queue_statistics_impl.h:50
void print(std::ostream &out) const final
Print to std::cout the value of all internal counters.
Definition: quantum_queue_statistics_impl.h:134
void decNumElements() final
Decrement this counter.
Definition: quantum_queue_statistics_impl.h:56