some work

This commit is contained in:
Denis Blank 2015-06-18 02:46:50 +02:00 committed by Naios
parent 702540e8fb
commit a9f480cf41
2 changed files with 20 additions and 6 deletions

View File

@ -42,7 +42,7 @@ namespace detail
/// The internal state of the continuable /// The internal state of the continuable
/// which is used to save certain internal types. /// which is used to save certain internal types.
template<typename... Args> template<typename... Args>
struct ContinuableState; class ContinuableState;
// ContinuableImpl forward declaration. // ContinuableImpl forward declaration.
template<typename _STy, typename _CTy> template<typename _STy, typename _CTy>
@ -71,12 +71,18 @@ namespace detail
struct is_continuable<_ContinuableImpl<_STy, _CTy>> struct is_continuable<_ContinuableImpl<_STy, _CTy>>
: public std::true_type { }; : public std::true_type { };
template<typename... _Cain, typename _Proxy> template<typename _WeakContextType>
struct ContinuableState<std::tuple<_Cain...>, _Proxy> class ContinuableState<_WeakContextType>
{ {
template<typename, typename>
friend class _ContinuableImpl;
typedef std::weak_ptr<_WeakContextType> weak_reference_t;
}; };
typedef ContinuableState<std::tuple<>, void> DefaultContinuableState; struct WeakContext { };
typedef ContinuableState<WeakContext> DefaultContinuableState;
// MSVC 12 has issues to detect the parameter pack otherwise. // MSVC 12 has issues to detect the parameter pack otherwise.
template<typename _NextRTy, typename... _NextATy> template<typename _NextRTy, typename... _NextATy>
@ -117,6 +123,8 @@ namespace detail
typedef Callback<_ATy...> CallbackFunction; typedef Callback<_ATy...> CallbackFunction;
typedef std::function<void(Callback<_ATy...>&&)> ForwardFunction; typedef std::function<void(Callback<_ATy...>&&)> ForwardFunction;
typedef typename ContinuableState<_STy...>::weak_reference_t WeakReference;
private: private:
/// Functional which expects a callback that is inserted from the Continuable /// Functional which expects a callback that is inserted from the Continuable
/// to chain everything together /// to chain everything together
@ -124,6 +132,8 @@ namespace detail
bool _released; bool _released;
WeakReference _reference;
template <typename _CTy> template <typename _CTy>
void invoke(_CTy&& callback) void invoke(_CTy&& callback)
{ {
@ -168,7 +178,8 @@ namespace detail
_ContinuableImpl(_ContinuableImpl const&) = delete; _ContinuableImpl(_ContinuableImpl const&) = delete;
/// Move construct /// Move construct
_ContinuableImpl(_ContinuableImpl&& right) template<typename _RSTy>
_ContinuableImpl(_ContinuableImpl<_RSTy, Callback<_ATy...>>&& right)
: _released(right._released), _callback_insert(std::move(right._callback_insert)) : _released(right._released), _callback_insert(std::move(right._callback_insert))
{ {
right._released = true; right._released = true;
@ -205,7 +216,8 @@ namespace detail
_ContinuableImpl& operator= (_ContinuableImpl const&) = delete; _ContinuableImpl& operator= (_ContinuableImpl const&) = delete;
/// Move construct assign /// Move construct assign
_ContinuableImpl& operator= (_ContinuableImpl&& right) template<typename _RSTy>
_ContinuableImpl& operator= (_ContinuableImpl<_RSTy, Callback<_ATy...>>&& right)
{ {
_released = right._released; _released = right._released;
right._released = true; right._released = true;

View File

@ -222,6 +222,8 @@ int main(int /*argc*/, char** /*argv*/)
//// Here we go //// Here we go
//entry(); //entry();
std::cout << "ok" << std::endl; std::cout << "ok" << std::endl;
return 0; return 0;
} }