some minor improvements

This commit is contained in:
Denis Blank 2015-06-11 17:46:44 +02:00 committed by Naios
parent c82a721b37
commit 4e9d87fd90
2 changed files with 15 additions and 67 deletions

View File

@ -27,7 +27,10 @@ namespace detail
} // detail
template <typename... Args>
struct ContinuableState
struct ContinuableState;
template <typename... Args>
struct ContinuableState<Args...>
{
};
@ -41,12 +44,11 @@ public:
typedef std::function<void(Callback<_ATy...>&&)> ForwardFunction;
private:
// Function 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
ForwardFunction _callback_insert;
bool released;
bool _released;
void Dispatch()
{
@ -55,26 +57,27 @@ private:
public:
/// Deleted copy construct
template <typename _RCTy, typename _RState>
Continuable(Continuable<_RCTy, _RState> const&) = delete;
explicit Continuable(Continuable<_RCTy, _RState> const&) = delete;
/// Move construct
template <typename _RCTy, typename _RState>
Continuable(Continuable<_RCTy, _RState>&& right) : released(right.released)
explicit Continuable(Continuable<_RCTy, _RState>&& right)
: _released(right._released)
{
right.released = true;
right._released = true;
}
// Construct through a ForwardFunction
template<typename _FTy>
Continuable(_FTy&& callback_insert)
: _callback_insert(std::forward<_FTy>(callback_insert)), released(false) { }
: _callback_insert(std::forward<_FTy>(callback_insert)), _released(false) { }
/// Destructor which calls the dispatch chain if needed.
~Continuable()
{
if (!released)
if (!_released)
{
released = true;
_released = true;
Dispatch();
}
}
@ -87,8 +90,8 @@ public:
template <typename _RCTy, typename _RState>
Continuable& operator= (Continuable<_RCTy, _RState>&& right)
{
released = right.released;
right.released = true;
_released = right._released;
right._released = true;
return *this;
}

View File

@ -9,61 +9,6 @@
#include "functional_unwrap.hpp"
/*
class fluent_step
{
bool released;
void release()
{
int i = 0;
std::cout << "-> release" << std::endl;
}
public:
fluent_step() : released(false)
{
std::cout << "+ construct" << std::endl;
}
~fluent_step()
{
std::cout << "- destruct" << std::endl;
if (!released)
release();
}
fluent_step(fluent_step const&) = delete;
fluent_step(fluent_step&& right) : released(false)
{
std::cout << "<-> move" << std::endl;
right.released = true;
}
fluent_step& operator= (fluent_step const&) = delete;
fluent_step& operator= (fluent_step&& right)
{
released = false;
right.released = true;
return *this;
}
template <typename Callback>
fluent_step then(Callback&& callback)
{
return std::move(*this);
}
};
template <typename _ATy = void()>
fluent_step make_waterfall()
{
return fluent_step();
}
struct ProtoContinueable
{
template <typename Callback>