From 10293e652055a5e741f3b9f87c14e7919bb2d267 Mon Sep 17 00:00:00 2001 From: Felipe Magno de Almeida Date: Tue, 20 Sep 2016 23:30:13 -0300 Subject: [PATCH] eo-cxx: Add progress to future and promise --- src/bindings/cxx/eo_cxx/eo_future.hh | 199 +++++++++++++++++++++++++---- src/bindings/cxx/eo_cxx/eo_promise.hh | 121 ++++-------------- src/bindings/cxx/eo_cxx/eo_promise_meta.hh | 44 +++++++ src/tests/eo_cxx/eo_cxx_test_promise.cc | 40 ++++++ 4 files changed, 285 insertions(+), 119 deletions(-) diff --git a/src/bindings/cxx/eo_cxx/eo_future.hh b/src/bindings/cxx/eo_cxx/eo_future.hh index 7154b5f..fbab965 100644 --- a/src/bindings/cxx/eo_cxx/eo_future.hh +++ b/src/bindings/cxx/eo_cxx/eo_future.hh @@ -116,17 +116,15 @@ struct shared_future_common Efl_Future* _future; }; -template -struct shared_future_1_type : private shared_future_common +template +struct shared_future_1_type : shared_future_common { typedef shared_future_common _base_type; using _base_type::_base_type; - using _base_type::swap; - using _base_type::valid; - using _base_type::native_handle; - using _base_type::wait; - typedef _base_type::native_handle_type native_handle_type; + shared_future_1_type() = default; + shared_future_1_type(shared_future_common const& other) + : _base_type(other) {} T get() const { @@ -162,20 +160,17 @@ struct shared_future_1_type : private shared_future_common wait_state->cv.notify_one(); } - typedef shared_future_1_type _self_type; + typedef shared_future_1_type _self_type; }; template -struct shared_race_future_1_type : private shared_future_common +struct shared_race_future_1_type : shared_future_common { typedef shared_future_common _base_type; using _base_type::_base_type; - using _base_type::swap; - using _base_type::valid; - using _base_type::native_handle; - using _base_type::wait; - typedef _base_type::native_handle_type native_handle_type; + shared_race_future_1_type(_base_type const& other) + : _base_type(other) {} T get() const { @@ -211,20 +206,18 @@ struct shared_race_future_1_type : private shared_future_common wait_state->cv.notify_one(); } - typedef shared_future_1_type _self_type; + typedef shared_race_future_1_type _self_type; }; - + template -struct shared_future_varargs_type : private shared_future_common +struct shared_future_varargs_type : shared_future_common { typedef shared_future_common _base_type; using _base_type::_base_type; - using _base_type::swap; - using _base_type::valid; - using _base_type::native_handle; - using _base_type::wait; - typedef _base_type::native_handle_type native_handle_type; + shared_future_varargs_type() = default; + shared_future_varargs_type(_base_type const& other) + : _base_type(other) {} typedef std::tuple tuple_type; @@ -314,17 +307,59 @@ struct shared_future_varargs_type : private shared_future_common } template -struct shared_future : private std::conditional>::type>, _impl::shared_future_varargs_type>::type +struct shared_future : private + std::conditional + < + sizeof...(Args) == 1 + , _impl::shared_future_1_type>::type> + , typename std::conditional + <_impl::is_progress>::type>::value + , typename std::conditional + + , _impl::shared_future_varargs_type + >::type + , _impl::shared_future_varargs_type + >::type + >::type { - typedef typename std::conditional>::type>, _impl::shared_future_varargs_type>::type _base_type; - + typedef typename + std::conditional + < + sizeof...(Args) == 1 + , _impl::shared_future_1_type + , typename std::conditional + <_impl::is_progress>::type>::value + , typename std::conditional + + , _impl::shared_future_varargs_type + >::type + , _impl::shared_future_varargs_type + >::type + >::type + _base_type; + typedef typename _impl::progress_param::type progress_param_type; + typedef typename _impl::progress_type::type progress_type; + typedef typename _base_type::native_handle_type native_handle_type; using _base_type::_base_type; using _base_type::swap; using _base_type::valid; using _base_type::get; using _base_type::wait; using _base_type::native_handle; - typedef typename _base_type::native_handle_type native_handle_type; + + shared_future() = default; + template + shared_future(shared_future const& other + , typename std::enable_if<_impl::is_progress_param_compatible + ::type>::value>::type* = nullptr) + : _base_type(static_cast< _impl::shared_future_common const&>(other)) + { + } + + template + friend struct shared_future; }; template @@ -350,7 +385,119 @@ template struct is_race_future> : std::true_type {}; } + +template