OnixS C++ CBOE CFE Binary Order Entry (BOE) Handler 1.12.0
API documentation
Loading...
Searching...
No Matches
Future.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable OnixS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19#pragma once
20
22
23#ifdef ONIXS_BATS_BOE_CXX11
24# include <utility>
25# include <exception>
26#endif
27
28namespace OnixS {
29namespace System {
30 class FutureSharedState;
31}}
32
33namespace OnixS {
34namespace CboeCFE {
35namespace Trading {
36namespace BOE {
37namespace Threading
38{
39
42{
52};
53
54namespace Implementation {
55
56class FutureHelper;
57
60{
61public:
66 {
67 return state_ != ONIXS_BATS_BOE_NULLPTR;
68 }
69
80 ONIXS_CBOE_CFE_BOE_API bool is_ready() const;
81
86 ONIXS_CBOE_CFE_BOE_API bool has_value() const;
87
92 ONIXS_CBOE_CFE_BOE_API bool has_exception() const;
93
94 enum
95 {
97 };
98
105 ONIXS_CBOE_CFE_BOE_API FutureStatus::Enum wait(int timeoutInMs) const;
106
107protected:
109 : state_()
110 {}
111
112 ONIXS_CBOE_CFE_BOE_API FutureBase(const FutureBase &other) ONIXS_BATS_BOE_NOEXCEPT;
113
114 ONIXS_CBOE_CFE_BOE_API FutureBase &operator=(const FutureBase &other) ONIXS_BATS_BOE_NOEXCEPT;
115
116#ifdef ONIXS_BATS_BOE_CXX11
117
118 ONIXS_CBOE_CFE_BOE_API FutureBase(FutureBase &&other) ONIXS_BATS_BOE_NOEXCEPT;
119
120 ONIXS_CBOE_CFE_BOE_API FutureBase &operator=(FutureBase &&other) ONIXS_BATS_BOE_NOEXCEPT;
121
122#endif
123
125 {};
126
128 ONIXS_CBOE_CFE_BOE_API FutureBase(const System::FutureSharedState *state) ONIXS_BATS_BOE_NOEXCEPT;
129
131 ONIXS_CBOE_CFE_BOE_API FutureBase(const System::FutureSharedState *state, moving_init_t) ONIXS_BATS_BOE_NOEXCEPT;
132
136 ONIXS_CBOE_CFE_BOE_API ~FutureBase() ONIXS_BATS_BOE_NOEXCEPT;
137
138 ONIXS_CBOE_CFE_BOE_API void swap(FutureBase &other) ONIXS_BATS_BOE_NOEXCEPT;
139
140 ONIXS_CBOE_CFE_BOE_API const void *getValuePtr() const;
141
142 ONIXS_CBOE_CFE_BOE_API void getVoid() const;
143
144private:
145 const System::FutureSharedState *state_;
146
147 friend class FutureHelper;
148};
149
150template <typename T>
152{
153 typedef const T &Type;
154};
155
156template <>
157struct FutureGetReturn<void>
158{
159 typedef void Type;
160};
161
162}
163
188template <typename T>
190{
191public:
194
198
201 {
202 FutureBase::operator=(other);
203 return *this;
204 }
205
206#ifdef ONIXS_BATS_BOE_CXX11
207
209 : FutureBase(std::move(other))
210 {}
211
212 FutureBase &operator=(SharedFuture<T> &&other) ONIXS_BATS_BOE_NOEXCEPT
213 {
214 FutureBase::operator=(std::move(other));
215 return *this;
216 }
217
218#endif
219
226 {
227 return *reinterpret_cast<const T *>(getValuePtr());
228 }
229
232 {
233 FutureBase::swap(other);
234 }
235
236private:
238 SharedFuture(const System::FutureSharedState *state)
239 : FutureBase(state)
240 {}
241
243 SharedFuture(const System::FutureSharedState *state, moving_init_t t) ONIXS_BATS_BOE_NOEXCEPT
244 : FutureBase(state, t) {}
245
246 friend class Implementation::FutureHelper;
247};
248
249template <>
250inline void SharedFuture<void>::get() const
251{
252 getVoid();
253}
254
255}}}}}
#define ONIXS_BATS_BOE_NOEXCEPT
Definition ABI.h:49
ONIXS_CBOE_CFE_BOE_API const void * getValuePtr() const
ONIXS_CBOE_CFE_BOE_API FutureBase & operator=(const FutureBase &other) ONIXS_BATS_BOE_NOEXCEPT
ONIXS_CBOE_CFE_BOE_API void swap(FutureBase &other) ONIXS_BATS_BOE_NOEXCEPT
ONIXS_CBOE_CFE_BOE_API FutureBase(const FutureBase &other) ONIXS_BATS_BOE_NOEXCEPT
ONIXS_CBOE_CFE_BOE_API ~FutureBase() ONIXS_BATS_BOE_NOEXCEPT
ONIXS_CBOE_CFE_BOE_API FutureBase(const System::FutureSharedState *state) ONIXS_BATS_BOE_NOEXCEPT
Initializes the instance with shared state.
ONIXS_CBOE_CFE_BOE_API FutureStatus::Enum wait(int timeoutInMs) const
ONIXS_CBOE_CFE_BOE_API FutureBase(const System::FutureSharedState *state, moving_init_t) ONIXS_BATS_BOE_NOEXCEPT
Initializes the instance with shared state.
SharedFuture(const SharedFuture< T > &other) ONIXS_BATS_BOE_NOEXCEPT
Copy constructor.
Definition Future.h:196
Implementation::FutureGetReturn< T >::Type get() const
Definition Future.h:225
void swap(SharedFuture< T > &other) ONIXS_BATS_BOE_NOEXCEPT
swaps two SharedFuture objects
Definition Future.h:231
SharedFuture< T > & operator=(const SharedFuture< T > &other) ONIXS_BATS_BOE_NOEXCEPT
Copy assignment.
Definition Future.h:200
State of a SharedFuture object (similar to std::future_status,.
Definition Future.h:42
@ timeout
the shared state did not become ready before specified timeout duration has passed.
Definition Future.h:48
@ deferred
the shared state contains a deferred function, so the result will be computed only when explicitly re...
Definition Future.h:50