15 #ifndef SHAKA_EMBEDDED_ASYNC_RESULTS_H_ 16 #define SHAKA_EMBEDDED_ASYNC_RESULTS_H_ 20 #include <type_traits> 48 using result_type =
typename std::conditional<std::is_same<T, void>::value,
56 AsyncResults(std::shared_future<variant_type> future) : future_(future) {}
73 return future_.valid();
85 template <
typename Rep,
typename Period>
87 const std::chrono::duration<Rep, Period>& timeout_duration)
const {
88 return future_.wait_for(timeout_duration);
95 template <
typename Clock,
typename Duration>
97 std::chrono::time_point<Clock, Duration>& timeout_time)
const {
98 return future_.wait_until(timeout_time);
107 return holds_alternative<Error>(future_.get());
114 template <
typename U = T,
typename =
typename std::enable_if<
115 !std::is_same<U, void>::value>::type>
117 return get<T>(future_.get());
125 return get<Error>(future_.get());
129 std::shared_future<variant_type> future_;
134 #endif // SHAKA_EMBEDDED_ASYNC_RESULTS_H_
AsyncResults(std::shared_future< variant_type > future)
const Error & error() const
typename std::conditional< std::is_same< T, void >::value, monostate, T >::type result_type
const U & results() const
std::future_status wait_for(const std::chrono::duration< Rep, Period > &timeout_duration) const
std::future_status wait_until(std::chrono::time_point< Clock, Duration > &timeout_time) const