QuantumLibrary
quantum_icoro_future_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_ICORO_FUTURE_BASE_H
17 #define BLOOMBERG_QUANTUM_ICORO_FUTURE_BASE_H
18 
19 #include <memory>
20 #include <future>
21 #include <chrono>
22 #include <quantum/interface/quantum_icoro_sync.h>
23 
24 namespace Bloomberg {
25 namespace quantum {
26 
27 //==============================================================================================
28 // interface ICoroFutureBase
29 //==============================================================================================
33 {
34  using Ptr = std::shared_ptr<ICoroFutureBase>;
35 
37  virtual ~ICoroFutureBase() = default;
38 
41  virtual bool valid() const = 0;
42 
46  virtual void wait(ICoroSync::Ptr sync) const = 0;
47 
53  virtual std::future_status waitFor(ICoroSync::Ptr sync,
54  std::chrono::milliseconds timeMs) const = 0;
55 };
56 
58 
59 }}
60 
61 #endif //BLOOMBERG_QUANTUM_ICORO_FUTURE_BASE_H
Exposes methods to access a coroutine-compatible future.
Definition: quantum_icoro_future_base.h:32
Definition: quantum_buffer_impl.h:22
virtual void wait(ICoroSync::Ptr sync) const =0
Waits for the future value.
virtual ~ICoroFutureBase()=default
Virtual destructor.
std::shared_ptr< ICoroSync > Ptr
Definition: quantum_icoro_sync.h:36
virtual std::future_status waitFor(ICoroSync::Ptr sync, std::chrono::milliseconds timeMs) const =0
Waits for the future value up to a maximum 'timeMs' milliseconds.
virtual bool valid() const =0
Determines if this future still has a shared state with the corresponding promise object.
std::shared_ptr< ICoroFutureBase > Ptr
Definition: quantum_icoro_future_base.h:34
ICoroFutureBase::Ptr ICoroFutureBasePtr
Definition: quantum_icoro_future_base.h:57