diff --git a/include/Continuable.h b/include/Continuable.h index 6874a92..f3cafbf 100644 --- a/include/Continuable.h +++ b/include/Continuable.h @@ -555,12 +555,13 @@ namespace detail // TODO Improve the lock here std::lock_guard guard(lock); { - std::cout << "storing..." << std::endl; + // Never call callbacks twice! + assert(partitions_left); // If all partitions have completed invoke the final callback. if (--partitions_left == 0) { - fu::invoke_from_tuple(callback, result); + fu::invoke_from_tuple(std::move(callback), std::move(result)); } } } diff --git a/test.cpp b/test.cpp index ae8b9f9..20f0b8a 100644 --- a/test.cpp +++ b/test.cpp @@ -413,15 +413,15 @@ int main(int /*argc*/, char** /*argv*/) return CastSpellPromise(20); }, [] { - return make_continuable([](Callback&& callback) + return make_continuable([](Callback>&& callback) { - callback(true, false, 0.3f, std::string("oh, all work is done!")); + callback(true, false, 0.3f, std::make_unique("oh, all work is done!")); }); }, TrivialPromise()) - .then([](SpellCastResult r0, SpellCastResult r1, bool r2, bool r3, double r4, std::string message) + .then([](SpellCastResult r0, SpellCastResult r1, bool r2, bool r3, double r4, std::unique_ptr message) { - return TrivialPromise("Lets see... ").then(Log(message)); + return TrivialPromise("Lets see... ").then(Log(*message)); }) .then([] {