Skip to content

Commit 826bb16

Browse files
authored
Merge pull request #149 from demin80/sequencer-module
Implemented experimental::Sequencer
2 parents 09990a1 + f06b72a commit 826bb16

15 files changed

+2141
-23
lines changed

quantum/quantum.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
#include <quantum/util/quantum_sequence_key_statistics.h>
8181
#include <quantum/util/quantum_sequencer.h>
8282
#include <quantum/util/quantum_sequencer_configuration.h>
83+
#include <quantum/util/quantum_sequencer_experimental.h>
84+
#include <quantum/util/quantum_sequencer_configuration_experimental.h>
8385
#include <quantum/util/quantum_spinlock_util.h>
8486
#include <quantum/util/quantum_util.h>
8587

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*
2+
** Copyright 2021 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+
#include <quantum/util/quantum_sequence_key_statistics.h>
23+
#include <quantum/interface/quantum_icoro_context_base.h>
24+
#include <list>
25+
#include <vector>
26+
#include <atomic>
27+
#include <memory>
28+
29+
namespace Bloomberg {
30+
namespace quantum {
31+
namespace experimental {
32+
33+
inline const std::string&
34+
SequencerConfigurationSchemaProvider::getJsonSchema()
35+
{
36+
static std::string schema = R"JSON(
37+
{
38+
"$schema" : "http://json-schema.org/draft-04/schema#",
39+
"$id" : "bloomberg:sequencer.quantum.json",
40+
"title": "Quantum sequencer settings",
41+
"type": "object",
42+
"properties": {
43+
"bucketCount": {
44+
"type": "number",
45+
"default": 100
46+
}
47+
},
48+
"additionalProperties": false,
49+
"required": []
50+
}
51+
)JSON";
52+
return schema;
53+
}
54+
55+
inline const std::string&
56+
SequencerConfigurationSchemaProvider::getJsonSchemaUri()
57+
{
58+
static std::string uri = "bloomberg:sequencer.quantum.json";
59+
return uri;
60+
}
61+
62+
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
63+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>&
64+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::setBucketCount(size_t bucketCount)
65+
{
66+
_bucketCount = bucketCount;
67+
return *this;
68+
}
69+
70+
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
71+
size_t
72+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::getBucketCount() const
73+
{
74+
return _bucketCount;
75+
}
76+
77+
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
78+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>&
79+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::setHash(const Hash& hash)
80+
{
81+
_hash = hash;
82+
return *this;
83+
}
84+
85+
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
86+
const Hash&
87+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::getHash() const
88+
{
89+
return _hash;
90+
}
91+
92+
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
93+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>&
94+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::setKeyEqual(const KeyEqual& keyEqual)
95+
{
96+
_keyEqual = keyEqual;
97+
return *this;
98+
}
99+
100+
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
101+
const KeyEqual&
102+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::getKeyEqual() const
103+
{
104+
return _keyEqual;
105+
}
106+
107+
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
108+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>&
109+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::setAllocator(const Allocator& allocator)
110+
{
111+
_allocator = allocator;
112+
return *this;
113+
}
114+
115+
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
116+
const Allocator&
117+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::getAllocator() const
118+
{
119+
return _allocator;
120+
}
121+
122+
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
123+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>&
124+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::setExceptionCallback(
125+
const ExceptionCallback&
126+
exceptionCallback)
127+
128+
{
129+
_exceptionCallback = exceptionCallback;
130+
return *this;
131+
}
132+
133+
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
134+
const typename SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::ExceptionCallback&
135+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::getExceptionCallback() const
136+
{
137+
return _exceptionCallback;
138+
}
139+
140+
}}}

quantum/util/impl/quantum_sequencer_configuration_impl.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
** Copyright 2018 Bloomberg Finance L.P.
2+
** Copyright 2021 Bloomberg Finance L.P.
33
**
44
** Licensed under the Apache License, Version 2.0 (the "License");
55
** you may not use this file except in compliance with the License.
@@ -99,10 +99,11 @@ SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::getBucketCount()
9999
}
100100

101101
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
102-
void
102+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>&
103103
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::setHash(const Hash& hash)
104104
{
105105
_hash = hash;
106+
return *this;
106107
}
107108

108109
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
@@ -113,10 +114,11 @@ SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::getHash() const
113114
}
114115

115116
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
116-
void
117+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>&
117118
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::setKeyEqual(const KeyEqual& keyEqual)
118119
{
119120
_keyEqual = keyEqual;
121+
return *this;
120122
}
121123

122124
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
@@ -127,10 +129,11 @@ SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::getKeyEqual() co
127129
}
128130

129131
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
130-
void
132+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>&
131133
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::setAllocator(const Allocator& allocator)
132134
{
133135
_allocator = allocator;
136+
return *this;
134137
}
135138

136139
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
@@ -141,17 +144,18 @@ SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::getAllocator() c
141144
}
142145

143146
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
144-
void
147+
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>&
145148
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::setExceptionCallback(
146149
const ExceptionCallback&
147150
exceptionCallback)
148151

149152
{
150153
_exceptionCallback = exceptionCallback;
154+
return *this;
151155
}
152156

153157
template <class SequenceKey, class Hash, class KeyEqual, class Allocator>
154-
const typename SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::ExceptionCallback&
158+
const typename SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::ExceptionCallback&
155159
SequencerConfiguration<SequenceKey, Hash, KeyEqual, Allocator>::getExceptionCallback() const
156160
{
157161
return _exceptionCallback;

0 commit comments

Comments
 (0)