QuantumLibrary
quantum_ithread_context_base.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_ITHREAD_CONTEXT_BASE_H
17 #define BLOOMBERG_QUANTUM_ITHREAD_CONTEXT_BASE_H
18 
19 #include <future>
20 #include <chrono>
21 #include <quantum/interface/quantum_icontext_base.h>
22 
23 namespace Bloomberg {
24 namespace quantum {
25 
26 template <class RET>
27 class Context;
28 
29 //==============================================================================================
30 // interface IThreadContextBase
31 //==============================================================================================
34 struct IThreadContextBase : public virtual IContextBase
35 {
36  using Ptr = std::shared_ptr<IThreadContextBase>;
37 
40  virtual void wait() const = 0;
41 
46  virtual std::future_status waitFor(std::chrono::milliseconds timeMs) const = 0;
47 
54  virtual void waitAt(int num) const = 0;
55 
64  virtual std::future_status waitForAt(int num, std::chrono::milliseconds timeMs) const = 0;
65 
68  virtual void waitAll() const = 0;
69 };
70 
72 
73 }}
74 
75 #endif //BLOOMBERG_QUANTUM_ITHREAD_CONTEXT_BASE_H
virtual std::future_status waitForAt(int num, std::chrono::milliseconds timeMs) const =0
Waits for the future in the 'num-th' continuation context to be ready for a maximum of 'timeMs' milli...
Definition: quantum_buffer_impl.h:22
std::shared_ptr< IContextBase > Ptr
Definition: quantum_icontext_base.h:35
virtual void waitAll() const =0
Wait for all the futures in the continuation chain to be ready.
virtual void wait() const =0
Waits for the future associated with this context to be ready.
Exposes methods to manipulate the thread context, especially future wait methods.
Definition: quantum_ithread_context_base.h:34
virtual std::future_status waitFor(std::chrono::milliseconds timeMs) const =0
Waits for the future associated with this context to be ready for a maximum of 'timeMs' milliseconds.
This interface exposes shared functionality between IThreadContext and ICoroContext.
Definition: quantum_icontext_base.h:33
IThreadContextBase::Ptr IThreadContextBasePtr
Definition: quantum_ithread_context_base.h:71
virtual void waitAt(int num) const =0
Waits for the future in the 'num-th' continuation context to be ready.
std::shared_ptr< IThreadContextBase > Ptr
Definition: quantum_ithread_context_base.h:36