try to fix rvalue references

This commit is contained in:
Naios 2015-07-02 21:11:32 +02:00
parent 3f7ad6f580
commit b9d2363abe
2 changed files with 7 additions and 6 deletions

View File

@ -555,12 +555,13 @@ namespace detail
// TODO Improve the lock here // TODO Improve the lock here
std::lock_guard<std::mutex> guard(lock); std::lock_guard<std::mutex> guard(lock);
{ {
std::cout << "storing..." << std::endl; // Never call callbacks twice!
assert(partitions_left);
// If all partitions have completed invoke the final callback. // If all partitions have completed invoke the final callback.
if (--partitions_left == 0) if (--partitions_left == 0)
{ {
fu::invoke_from_tuple(callback, result); fu::invoke_from_tuple(std::move(callback), std::move(result));
} }
} }
} }

View File

@ -413,15 +413,15 @@ int main(int /*argc*/, char** /*argv*/)
return CastSpellPromise(20); return CastSpellPromise(20);
}, },
[] { [] {
return make_continuable([](Callback<bool, bool, double, std::string>&& callback) return make_continuable([](Callback<bool, bool, double, std::unique_ptr<std::string>>&& callback)
{ {
callback(true, false, 0.3f, std::string("oh, all work is done!")); callback(true, false, 0.3f, std::make_unique<std::string>("oh, all work is done!"));
}); });
}, },
TrivialPromise()) 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<std::string> message)
{ {
return TrivialPromise("Lets see... ").then(Log(message)); return TrivialPromise("Lets see... ").then(Log(*message));
}) })
.then([] .then([]
{ {