QuantumLibrary
quantum_icoro_future.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_H
17 #define BLOOMBERG_QUANTUM_ICORO_FUTURE_H
18 
19 #include <quantum/interface/quantum_icontext_base.h>
20 #include <quantum/interface/quantum_icoro_future_base.h>
21 #include <quantum/quantum_traits.h>
22 
23 namespace Bloomberg {
24 namespace quantum {
25 
26 template <class T>
27 class Future;
28 
29 //==============================================================================================
30 // interface ICoroFuture
31 //==============================================================================================
34 template <class T>
36 {
38  using Ptr = std::shared_ptr<ICoroFuture<T>>;
39  using Impl = Future<T>;
40 
46  template <class V = T>
48 
54  template <class V = T>
55  const NonBufferRetType<V>& getRef(ICoroSync::Ptr sync) const;
56 
64  template <class V = T>
65  BufferRetType<V> pull(ICoroSync::Ptr sync, bool& isBufferClosed);
66 };
67 
68 template <class T>
70 
71 template <class T>
73 
74 }}
75 
76 #endif //BLOOMBERG_QUANTUM_ICORO_FUTURE_H
Exposes methods to access a coroutine-compatible future.
Definition: quantum_icoro_future_base.h:32
Definition: quantum_buffer_impl.h:22
typename ICoroFuture< T >::Ptr CoroFuturePtr
Definition: quantum_icoro_future.h:72
std::shared_ptr< ICoroFuture< T > > Ptr
Definition: quantum_icoro_future.h:38
std::shared_ptr< ICoroSync > Ptr
Definition: quantum_icoro_sync.h:36
Exposes methods to access a coroutine-compatible future.
Definition: quantum_icoro_future.h:35
std::enable_if_t<!Traits::IsBuffer< T >::value, typename Traits::IsBuffer< T >::Type > NonBufferRetType
Definition: quantum_traits.h:95
Class representing a promised future. Can only be instantiated via a Promise object.
Definition: quantum_icoro_future.h:27
const NonBufferRetType< V > & getRef(ICoroSync::Ptr sync) const
Get a reference the future value.
Definition: quantum_future_impl.h:75
std::enable_if_t< Traits::IsBuffer< T >::value, typename Traits::IsBuffer< T >::Type > BufferRetType
Definition: quantum_traits.h:93
BufferRetType< V > pull(ICoroSync::Ptr sync, bool &isBufferClosed)
Pull a single value from the future buffer.
Definition: quantum_future_impl.h:82
Definition: quantum_icontext_base.h:25
NonBufferRetType< V > get(ICoroSync::Ptr sync)
Get the future value.
Definition: quantum_future_impl.h:68