Calculate the offset

This commit is contained in:
Naios 2015-07-02 16:16:46 +02:00
parent 7e0b63a62b
commit 45aa2237c1
2 changed files with 40 additions and 5 deletions

View File

@ -19,6 +19,9 @@
#ifndef _CONTINUABLE_H_
#define _CONTINUABLE_H_
#include <atomic>
#include <mutex>
#include "Callback.h"
template<typename...>
@ -456,7 +459,12 @@ namespace detail
template<std::size_t Position, typename Args, typename Pack, typename Next, typename... Rest>
struct multiple_result_maker<Position, Args, Pack, Next, Rest...>
: multiple_result_maker<
Position + 1,
Position +
std::tuple_size<
typename identity_to_tuple<
typename unary_chainer_t<Next, _ATy...>::callback_arguments_t
>::type
>::value,
typename concat_identities<
Args,
typename unary_chainer_t<Next, _ATy...>::callback_arguments_t
@ -490,6 +498,16 @@ namespace detail
typedef std::function<continuable_t()> return_t;
struct ResultStorage
{
ResultStorage(std::size_t count_)
: count(count_) { }
std::size_t count;
std::tuple<Args...> result;
};
template <typename... _ATy, typename... _CTy>
static return_t create(_CTy&&... functionals)
{
@ -498,9 +516,15 @@ namespace detail
// Fake continuable which wraps all continuables together
return make_continuable([](Callback<Args...>&& callback)
{
std::shared_ptr<ResultStorage> result(
new ResultStorage(sizeof...(_CTy)));
// auto shared = std::make_shared(ResultStorage());
int i = 0;
++i;
std::cout << "hey all was called!" << std::endl;
});
};
}

View File

@ -152,6 +152,7 @@ inline auto apply(F && f, T && t)
int main(int /*argc*/, char** /*argv*/)
{
/*
CastSpellPromise(1)
.then([](SpellCastResult)
{
@ -210,7 +211,7 @@ int main(int /*argc*/, char** /*argv*/)
{
std::cout << "Finished" << std::endl;
});
*/
//Continuable<bool> cb = make_continuable([](Callback<bool>&& callback)
//{
@ -331,7 +332,8 @@ int main(int /*argc*/, char** /*argv*/)
decltype(CastSpellPromise(2)),
decltype(TrivialPromise()),
std::function<Continuable<float, double>()>,
std::function<Continuable<>()>
std::function<Continuable<>()>,
std::function<Continuable<bool>()>
> maker;
@ -406,7 +408,7 @@ int main(int /*argc*/, char** /*argv*/)
});
*/
auto promise = make_continuable()
make_continuable()
.all(
[] {
return CastSpellPromise(10)
@ -414,8 +416,17 @@ int main(int /*argc*/, char** /*argv*/)
},
[] {
return CastSpellPromise(20);
},
[] {
return make_continuable([](Callback<bool, bool>&& callback)
{
callback(true, false);
});
},
[] {
return CastSpellPromise(25);
})
.then([](SpellCastResult, SpellCastResult)
.then([](SpellCastResult, SpellCastResult, bool, bool, SpellCastResult)
{
})