OnixS C++ CME iLink 3 Binary Order Entry Handler 1.18.9
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
20#pragma once
21
23
24#if defined (ONIXS_ILINK3_CXX11)
25# include <exception>
26#endif
27
28namespace OnixS {
29
30namespace System {
31class FutureSharedState;
32}
33
34namespace CME {
35namespace iLink3 {
36namespace Threading {
37
40{
50};
51
52namespace Implementation {
53
54class FutureHelper;
55
58{
59public:
64 return state_ != ONIXS_ILINK3_NULLPTR;
65 }
66
78
84
90
91#if defined (ONIXS_ILINK3_CXX11)
92
97 ONIXS_ILINK3_EXPORTED std::exception_ptr get_exception_ptr() const;
98
99#endif
100
101 enum { InfiniteTimeout = -1 };
102
110
111protected:
113 : state_() {}
114
116
118
119#if defined (ONIXS_ILINK3_CXX11)
120
122
124
125#endif
126
127 struct moving_init_t {};
128
130 ONIXS_ILINK3_EXPORTED FutureBase(const System::FutureSharedState * state) ONIXS_ILINK3_NOTHROW;
131
133 ONIXS_ILINK3_EXPORTED FutureBase(const System::FutureSharedState * state, moving_init_t) ONIXS_ILINK3_NOTHROW;
134
139
141
142 ONIXS_ILINK3_EXPORTED const void * getValuePtr() const;
143
145
146private:
147 const System::FutureSharedState * state_;
148
149 friend class FutureHelper;
150};
151
152template<typename T>
154 typedef const T & Type;
155};
156
157template<>
158struct FutureGetReturn<void> {
159 typedef void Type;
160};
161
162}
163
188template <typename T>
190{
191public:
194
198
201 FutureBase::operator=(other);
202 return *this;
203 }
204
205#if defined (ONIXS_ILINK3_CXX11)
206
208 : FutureBase(std::move(other)) {}
209
211 FutureBase::operator=(std::move(other));
212 return *this;
213 }
214
215#endif
216
223 return *reinterpret_cast<const T *>(getValuePtr());
224 }
225
228 FutureBase::swap(other);
229 }
230
231private:
233 SharedFuture(const System::FutureSharedState * state)
234 : FutureBase(state) {}
235
237 SharedFuture(const System::FutureSharedState * state, moving_init_t t) ONIXS_ILINK3_NOTHROW
238 : FutureBase(state, t) {}
239
240 friend class Implementation::FutureHelper;
241};
242
243template<>
244inline void SharedFuture<void>::get() const {
245 getVoid();
246}
247
248}
249}
250}
251}
#define ONIXS_ILINK3_NULLPTR
Definition Compiler.h:182
#define ONIXS_ILINK3_EXPORTED
Definition Compiler.h:175
#define ONIXS_ILINK3_NOTHROW
Definition Compiler.h:176
Base implementation of SharedFuture<T>.
Definition Future.h:58
FutureBase & operator=(const FutureBase &other) noexcept
bool has_exception() const
Returns true if the asynchronous result associated with this Future has a stored exception,...
FutureStatus::Enum wait(int timeoutInMs) const
Waits for the result to become available during the timeout.
FutureBase(const System::FutureSharedState *state) noexcept
Initializes the instance with shared state.
bool has_value() const
Returns true if the asynchronous result associated with this Future has a stored value,...
bool valid() const noexcept
Check if a future instance is associated with an asynchronous result.
Definition Future.h:63
~FutureBase() noexcept
Destroys a future object.
FutureBase(const System::FutureSharedState *state, moving_init_t) noexcept
Initializes the instance with shared state.
std::exception_ptr get_exception_ptr() const
Returns the stored exception.
bool is_ready() const
Returns true if the asynchronous result associated with this Future is ready (has a value or exceptio...
FutureBase & operator=(FutureBase &&other) noexcept
Represents a future result of an asynchronous operation - a result that will eventually appear in the...
Definition Future.h:190
void swap(SharedFuture< T > &other) noexcept
swaps two SharedFuture objects
Definition Future.h:227
SharedFuture(const SharedFuture< T > &other) noexcept
Copy constructor.
Definition Future.h:196
SharedFuture(SharedFuture< T > &&other) noexcept
Definition Future.h:207
FutureBase & operator=(SharedFuture< T > &&other) noexcept
Definition Future.h:210
Implementation::FutureGetReturn< T >::Type get() const
Returns the result.
Definition Future.h:222
SharedFuture< T > & operator=(const SharedFuture< T > &other) noexcept
Copy assignment.
Definition Future.h:200
State of a SharedFuture object (similar to std::future_status,.
Definition Future.h:40
@ timeout
the shared state did not become ready before specified timeout duration has passed.
Definition Future.h:46
@ ready
the shared state is ready.
Definition Future.h:44
@ deferred
the shared state contains a deferred function, so the result will be computed only when explicitly re...
Definition Future.h:48