diff --git a/fluent/Continuable.h b/fluent/Continuable.h index e78be17..25074cb 100644 --- a/fluent/Continuable.h +++ b/fluent/Continuable.h @@ -32,18 +32,60 @@ struct ContinuableState }; template > -struct Continuable; +class Continuable; template -struct Continuable, _State> +class Continuable, _State> { +public: typedef std::function&&)> ForwardFunction; +private: + // Function which expects a callback that is inserted from the Continuable // to chain everything together ForwardFunction _callback_insert; - Continuable() { } + bool released; + + void Dispatch() + { + } + +public: + /// Deleted copy construct + template + Continuable(Continuable<_RCTy, _RState> const&) = delete; + + /// Move construct + template + Continuable(Continuable<_RCTy, _RState>&& right) : released(false) + { + right.released = true; + } + + /// Destructor which calls the dispatch chain if needed. + ~Continuable() + { + if (!released) + { + released = true; + Dispatch(); + } + } + + /// Deleted copy assign + template + Continuable& operator= (Continuable<_RCTy, _RState> const&) = delete; + + /// Move construct assign + template + Continuable& operator= (Continuable<_RCTy, _RState>&&) + { + released = right.released; + right.released = true; + return *this; + } template Continuable(_FTy&& callback_insert) @@ -52,7 +94,7 @@ struct Continuable, _State> template Continuable> then(_CTy&&) { - return Continuable>(); + return Continuable>(std::move(*this)); } };