mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
first working example!
This commit is contained in:
parent
e82a2be267
commit
3501d42a80
@ -565,7 +565,7 @@ namespace detail
|
|||||||
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
test.cpp
18
test.cpp
@ -73,10 +73,7 @@ Continuable<SpellCastResult> CastSpellPromise(int id)
|
|||||||
// Void instant returning continuable promise for testing purposes
|
// Void instant returning continuable promise for testing purposes
|
||||||
Continuable<> TrivialPromise(std::string const& msg = "")
|
Continuable<> TrivialPromise(std::string const& msg = "")
|
||||||
{
|
{
|
||||||
return Log(msg).then(make_continuable([=](Callback<>&& callback)
|
return Log(msg);
|
||||||
{
|
|
||||||
callback();
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Continuable<bool> Validate()
|
Continuable<bool> Validate()
|
||||||
@ -416,21 +413,22 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
return CastSpellPromise(20);
|
return CastSpellPromise(20);
|
||||||
},
|
},
|
||||||
[] {
|
[] {
|
||||||
return make_continuable([](Callback<bool, bool>&& callback)
|
return make_continuable([](Callback<bool, bool, double, std::string>&& callback)
|
||||||
{
|
{
|
||||||
callback(true, false);
|
callback(true, false, 0.3f, std::string("huhu all work is done!"));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
TrivialPromise())
|
TrivialPromise())
|
||||||
.then([](SpellCastResult, SpellCastResult, bool, bool)
|
.then([](SpellCastResult r0, SpellCastResult r1, bool r2, bool r3, double r4, std::string message)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
return Log(message);
|
||||||
})
|
})
|
||||||
.then([]
|
.then([]
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
});
|
||||||
.then(TrivialPromise());
|
|
||||||
|
|
||||||
std::cout << "ok" << std::endl;
|
std::cout << "ok" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user