mirror of
https://github.com/Naios/continuable.git
synced 2026-02-07 10:19:46 +08:00
Calculate the offset
This commit is contained in:
parent
1d9fee2741
commit
6fedd81df1
@ -19,6 +19,9 @@
|
|||||||
#ifndef _CONTINUABLE_H_
|
#ifndef _CONTINUABLE_H_
|
||||||
#define _CONTINUABLE_H_
|
#define _CONTINUABLE_H_
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include "Callback.h"
|
#include "Callback.h"
|
||||||
|
|
||||||
template<typename...>
|
template<typename...>
|
||||||
@ -456,7 +459,12 @@ namespace detail
|
|||||||
template<std::size_t Position, typename Args, typename Pack, typename Next, typename... Rest>
|
template<std::size_t Position, typename Args, typename Pack, typename Next, typename... Rest>
|
||||||
struct multiple_result_maker<Position, Args, Pack, Next, Rest...>
|
struct multiple_result_maker<Position, Args, Pack, Next, Rest...>
|
||||||
: multiple_result_maker<
|
: 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<
|
typename concat_identities<
|
||||||
Args,
|
Args,
|
||||||
typename unary_chainer_t<Next, _ATy...>::callback_arguments_t
|
typename unary_chainer_t<Next, _ATy...>::callback_arguments_t
|
||||||
@ -490,6 +498,16 @@ namespace detail
|
|||||||
|
|
||||||
typedef std::function<continuable_t()> return_t;
|
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>
|
template <typename... _ATy, typename... _CTy>
|
||||||
static return_t create(_CTy&&... functionals)
|
static return_t create(_CTy&&... functionals)
|
||||||
{
|
{
|
||||||
@ -498,9 +516,15 @@ namespace detail
|
|||||||
// Fake continuable which wraps all continuables together
|
// Fake continuable which wraps all continuables together
|
||||||
return make_continuable([](Callback<Args...>&& callback)
|
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;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
19
test.cpp
19
test.cpp
@ -152,6 +152,7 @@ inline auto apply(F && f, T && t)
|
|||||||
|
|
||||||
int main(int /*argc*/, char** /*argv*/)
|
int main(int /*argc*/, char** /*argv*/)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
CastSpellPromise(1)
|
CastSpellPromise(1)
|
||||||
.then([](SpellCastResult)
|
.then([](SpellCastResult)
|
||||||
{
|
{
|
||||||
@ -210,7 +211,7 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
{
|
{
|
||||||
std::cout << "Finished" << std::endl;
|
std::cout << "Finished" << std::endl;
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
//Continuable<bool> cb = make_continuable([](Callback<bool>&& callback)
|
//Continuable<bool> cb = make_continuable([](Callback<bool>&& callback)
|
||||||
//{
|
//{
|
||||||
|
|
||||||
@ -331,7 +332,8 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
decltype(CastSpellPromise(2)),
|
decltype(CastSpellPromise(2)),
|
||||||
decltype(TrivialPromise()),
|
decltype(TrivialPromise()),
|
||||||
std::function<Continuable<float, double>()>,
|
std::function<Continuable<float, double>()>,
|
||||||
std::function<Continuable<>()>
|
std::function<Continuable<>()>,
|
||||||
|
std::function<Continuable<bool>()>
|
||||||
|
|
||||||
> maker;
|
> maker;
|
||||||
|
|
||||||
@ -406,7 +408,7 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
auto promise = make_continuable()
|
make_continuable()
|
||||||
.all(
|
.all(
|
||||||
[] {
|
[] {
|
||||||
return CastSpellPromise(10)
|
return CastSpellPromise(10)
|
||||||
@ -414,8 +416,17 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
},
|
},
|
||||||
[] {
|
[] {
|
||||||
return CastSpellPromise(20);
|
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user