QuantumLibrary
quantum_itask.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_ITASK_H
17 #define BLOOMBERG_QUANTUM_ITASK_H
18 
19 #include <memory>
20 #include <limits>
21 #include <quantum/quantum_traits.h>
22 #include <quantum/interface/quantum_iterminate.h>
23 
24 namespace Bloomberg {
25 namespace quantum {
26 
27 //==============================================================================================
28 // interface ITask
29 //==============================================================================================
32 struct ITask : public ITerminate
33 {
34  using Ptr = std::shared_ptr<ITask>;
35  using WeakPtr = std::weak_ptr<ITask>;
36 
37  enum class Type : int
38  {
40  };
41 
42  enum class RetCode : int
43  {
44  Success = 0,
45  Running = std::numeric_limits<int>::max(),
46  Exception = (int)Running-1,
47  NotCallable = (int)Running-2,
48  };
49 
50  ~ITask() = default;
51 
52  virtual int run() = 0;
53 
54  virtual void setQueueId(int queueId) = 0;
55 
56  virtual int getQueueId() = 0;
57 
58  virtual Type getType() const = 0;
59 
60  virtual bool isBlocked() const = 0;
61 
62  virtual bool isSleeping(bool updateTimer = false) = 0;
63 
64  virtual bool isHighPriority() const = 0;
65 };
66 
69 
70 }}
71 
72 #endif //BLOOMBERG_QUANTUM_ITASK_H
Definition: quantum_buffer_impl.h:22
Type
Definition: quantum_itask.h:37
virtual Type getType() const =0
std::shared_ptr< ITask > Ptr
Definition: quantum_itask.h:34
ITask::WeakPtr ITaskWeakPtr
Definition: quantum_itask.h:68
virtual void setQueueId(int queueId)=0
RetCode
Definition: quantum_itask.h:42
std::weak_ptr< ITask > WeakPtr
Definition: quantum_itask.h:35
virtual bool isBlocked() const =0
virtual bool isSleeping(bool updateTimer=false)=0
Interface to a task. For internal use only.
Definition: quantum_itask.h:32
ITask::Ptr ITaskPtr
Definition: quantum_itask.h:67
virtual bool isHighPriority() const =0
virtual int getQueueId()=0