QuantumLibrary
quantum_sequencer_configuration.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 #ifndef BLOOMBERG_QUANTUM_SEQUENCER_CONFIGURATION_H
17 #define BLOOMBERG_QUANTUM_SEQUENCER_CONFIGURATION_H
18 
19 #include <functional>
20 #include <memory>
21 #include <exception>
22 
23 namespace Bloomberg {
24 namespace quantum {
25 
26 struct SequenceKeyData;
27 
28 //==============================================================================================
29 // class SequencerConfiguration
30 //==============================================================================================
37 template <class SequenceKey,
38  class Hash = std::hash<SequenceKey>,
39  class KeyEqual = std::equal_to<SequenceKey>,
40  class Allocator = std::allocator<std::pair<const SequenceKey, SequenceKeyData>>>
42 {
43 public:
44 
48  using ExceptionCallback = std::function<void(std::exception_ptr exception, void* opaque)>;
49 
50 public:
55  void setControlQueueId(int controlQueueId);
56 
59  int getControlQueueId() const;
60 
63  void setBucketCount(size_t bucketCount);
64 
67  size_t getBucketCount() const;
68 
71  void setHash(const Hash& hash);
72 
75  const Hash& getHash() const;
76 
79  void setKeyEqual(const KeyEqual& keyEqual);
80 
83  const KeyEqual& getKeyEqual() const;
84 
87  void setAllocator(const Allocator& allocator);
88 
91  const Allocator& getAllocator() const;
92 
95  void setExceptionCallback(const ExceptionCallback& exceptionCallback);
96 
100 
101 private:
102  int _controllerQueueId{0};
103  size_t _bucketCount{0};
104  Hash _hash;
105  KeyEqual _keyEqual;
106  Allocator _allocator;
107  ExceptionCallback _exceptionCallback;
108 };
109 
110 }}
111 
112 #include <quantum/util/impl/quantum_sequencer_configuration_impl.h>
113 
114 #endif //BLOOMBERG_QUANTUM_SEQUENCER_CONFIGURATION_H
Definition: quantum_buffer_impl.h:22
const KeyEqual & getKeyEqual() const
Gets the comparison function to be used for all SequenceKey comparisons for the context hash map.
Definition: quantum_sequencer_configuration_impl.h:88
void setKeyEqual(const KeyEqual &keyEqual)
Sets the comparison function to be used for all SequenceKey comparisons for the context hash map.
Definition: quantum_sequencer_configuration_impl.h:81
Definition: quantum_allocator.h:54
Implementation of a configuration class for Sequencer.
Definition: quantum_sequencer_configuration.h:41
const Allocator & getAllocator() const
Gets the allocator for all SequenceKey comparisons for the context hash map.
Definition: quantum_sequencer_configuration_impl.h:102
const ExceptionCallback & getExceptionCallback() const
Gets the exception callback for Scheduler.
Definition: quantum_sequencer_configuration_impl.h:119
void setAllocator(const Allocator &allocator)
Sets the allocator for all SequenceKey comparisons for the context hash map.
Definition: quantum_sequencer_configuration_impl.h:95
void setHash(const Hash &hash)
Sets the hash function to be used for the context hash map.
Definition: quantum_sequencer_configuration_impl.h:67
std::function< void(std::exception_ptr exception, void *opaque)> ExceptionCallback
Callback for unhandled exceptions in tasks posted to Sequencer.
Definition: quantum_sequencer_configuration.h:48
const Hash & getHash() const
Gets the hash function to be used for the context hash map.
Definition: quantum_sequencer_configuration_impl.h:74
int getControlQueueId() const
Gets the id of the control queue.
Definition: quantum_sequencer_configuration_impl.h:46
size_t getBucketCount() const
gets the minimal number of buckets to be used for the context hash map
Definition: quantum_sequencer_configuration_impl.h:60
void setControlQueueId(int controlQueueId)
Sets the id of the control queue.
Definition: quantum_sequencer_configuration_impl.h:39
void setBucketCount(size_t bucketCount)
Sets the minimal number of buckets to be used for the context hash map.
Definition: quantum_sequencer_configuration_impl.h:53
void setExceptionCallback(const ExceptionCallback &exceptionCallback)
Sets the exception callback for Scheduler.
Definition: quantum_sequencer_configuration_impl.h:109