QuantumLibrary
quantum_ipromise_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_IPROMISE_BASE_H
17 #define BLOOMBERG_QUANTUM_IPROMISE_BASE_H
18 
19 #include <exception>
20 #include <quantum/interface/quantum_iterminate.h>
21 #include <quantum/interface/quantum_ifuture.h>
22 #include <quantum/quantum_traits.h>
23 
24 namespace Bloomberg {
25 namespace quantum {
26 
27 //==============================================================================================
28 // interface IPromiseBase
29 //==============================================================================================
32 struct IPromiseBase : public ITerminate
33 {
34  using Ptr = std::shared_ptr<IPromiseBase>;
35 
38  virtual bool valid() const = 0;
39 
46  virtual int setException(std::exception_ptr ex) = 0;
47 
50  virtual IThreadFutureBase::Ptr getIThreadFutureBase() const = 0;
51 
54  virtual ICoroFutureBase::Ptr getICoroFutureBase() const = 0;
55 };
56 
58 
59 }}
60 
61 #endif //BLOOMBERG_QUANTUM_IPROMISE_BASE_H
Definition: quantum_buffer_impl.h:22
std::shared_ptr< IPromiseBase > Ptr
Definition: quantum_ipromise_base.h:34
virtual ICoroFutureBase::Ptr getICoroFutureBase() const =0
Get a coroutine-compatible interface used to access the associated future.
virtual IThreadFutureBase::Ptr getIThreadFutureBase() const =0
Get a thread-compatible interface used to access the associated future.
IPromiseBase::Ptr IPromiseBasePtr
Definition: quantum_ipromise_base.h:57
std::shared_ptr< ICoroFutureBase > Ptr
Definition: quantum_icoro_future_base.h:34
std::shared_ptr< IThreadFutureBase > Ptr
Definition: quantum_ithread_future_base.h:34
Exposes methods to manipulate and access a promise.
Definition: quantum_ipromise_base.h:32
virtual bool valid() const =0
Determines if this promise still has a shared state with the corresponding future object.
virtual int setException(std::exception_ptr ex)=0
Set an exception in this promise.