QuantumLibrary
quantum_iterminate.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_ITERMINATE_H
17 #define BLOOMBERG_QUANTUM_ITERMINATE_H
18 
19 #include <atomic>
20 
21 namespace Bloomberg {
22 namespace quantum {
23 
24 //==============================================================================================
25 // interface ITerminate
26 //==============================================================================================
30 struct ITerminate
31 {
33  virtual ~ITerminate() = default;
34 
37  virtual void terminate() = 0;
38 
39  //==============================================================================================
40  // class ITerminate::Guard
41  //==============================================================================================
45  class Guard
46  {
47  public:
50  explicit Guard(ITerminate& object);
51 
53  ~Guard();
54  private:
55  ITerminate& _object;
56  };
57 };
58 
59 }}
60 
61 #include <quantum/impl/quantum_iterminate_impl.h>
62 
63 #endif //BLOOMBERG_QUANTUM_ITERMINATE_H
Definition: quantum_buffer_impl.h:22
virtual void terminate()=0
Terminates the object.
Guard(ITerminate &object)
Constructor.
Definition: quantum_iterminate_impl.h:26
~Guard()
Destructor. Calls the terminate() method of the underlying object.
Definition: quantum_iterminate_impl.h:31
Definition: quantum_iterminate.h:45
virtual ~ITerminate()=default
Virtual destructor. This function is explicitly left empty.