mirror of
https://github.com/Naios/continuable.git
synced 2026-01-01 03:12:12 +08:00
disallow move assign of continuables
This commit is contained in:
parent
f70efcfc01
commit
5e5273fae7
@ -40,22 +40,6 @@ namespace detail
|
||||
struct is_continuable<Continuable<Args...>>
|
||||
: std::true_type { };
|
||||
|
||||
/// Creates an empty callback.
|
||||
template<typename>
|
||||
struct create_empty_callback;
|
||||
|
||||
template<typename... Args>
|
||||
struct create_empty_callback<std::function<void(std::function<void(Args...)>&&)>>
|
||||
{
|
||||
static auto create()
|
||||
-> Callback<Args...>
|
||||
{
|
||||
return [](Args&&...)
|
||||
{
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
template<typename...>
|
||||
struct continuable_corrector;
|
||||
|
||||
@ -131,22 +115,17 @@ public:
|
||||
_released = true;
|
||||
|
||||
// Invoke everything with an empty callback
|
||||
_callback_insert(detail::create_empty_callback<ForwardFunction>::create());
|
||||
_callback_insert([](_ATy&&...)
|
||||
{
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Deleted copy assign
|
||||
Continuable& operator= (Continuable const&) = delete;
|
||||
|
||||
/// Move construct assign
|
||||
Continuable& operator= (Continuable&& right)
|
||||
{
|
||||
_released = right._released;
|
||||
right._released = true;
|
||||
|
||||
_callback_insert = std::move(right._callback_insert);
|
||||
return *this;
|
||||
}
|
||||
/// Deleted move assign
|
||||
Continuable& operator= (Continuable&&) = delete;
|
||||
|
||||
/// Waits for this continuable and invokes the given callback.
|
||||
template<typename _CTy>
|
||||
|
||||
15
test.cpp
15
test.cpp
@ -151,12 +151,25 @@ TEST_CASE("Continuable invocation on destruct", "[Continuable]")
|
||||
|
||||
REQUIRE(invoked);
|
||||
}
|
||||
|
||||
SECTION("Continuables are not invoked after transferred")
|
||||
{
|
||||
Continuable<> continuable = make_continuable(std::move(invokeable));
|
||||
|
||||
{
|
||||
Continuable<> cache = std::move(continuable);
|
||||
|
||||
REQUIRE_FALSE(invoked);
|
||||
}
|
||||
|
||||
REQUIRE(invoked);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Continuable continuation chaining using Continuable::then", "[Continuable]")
|
||||
{
|
||||
SECTION("Continuables are invalidated on chaining (no duplicated call)")
|
||||
{
|
||||
std::size_t invoked = 0;
|
||||
//std::size_t invoked = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user