mirror of
https://github.com/Naios/continuable.git
synced 2026-02-08 18:56:40 +08:00
more work
This commit is contained in:
parent
46af9b3531
commit
e2de1a20bb
@ -104,9 +104,6 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Developing
|
|
||||||
Continuable() : _released(true) { }
|
|
||||||
|
|
||||||
/// Deleted copy construct
|
/// Deleted copy construct
|
||||||
Continuable(Continuable const&) = delete;
|
Continuable(Continuable const&) = delete;
|
||||||
|
|
||||||
@ -410,6 +407,7 @@ namespace detail
|
|||||||
"Given continuable must be passed as r-value!");
|
"Given continuable must be passed as r-value!");
|
||||||
|
|
||||||
// Trick C++11 lambda capture rules for non copyable but moveable continuables.
|
// Trick C++11 lambda capture rules for non copyable but moveable continuables.
|
||||||
|
// TODO Use the stack instead of heap variables.
|
||||||
std::shared_ptr<typename std::decay<_CTy>::type> shared_continuable =
|
std::shared_ptr<typename std::decay<_CTy>::type> shared_continuable =
|
||||||
std::make_shared<typename std::decay<_CTy>::type>(std::forward<_CTy>(continuable));
|
std::make_shared<typename std::decay<_CTy>::type>(std::forward<_CTy>(continuable));
|
||||||
|
|
||||||
@ -503,14 +501,23 @@ namespace detail
|
|||||||
|
|
||||||
typedef functional_traits<_ATy...> traits_t;
|
typedef functional_traits<_ATy...> traits_t;
|
||||||
|
|
||||||
struct ResultStorage
|
class ResultStorage
|
||||||
{
|
{
|
||||||
ResultStorage(std::size_t count_)
|
std::size_t partitions_left;
|
||||||
: count(count_) { }
|
|
||||||
|
|
||||||
std::size_t count;
|
|
||||||
|
|
||||||
std::tuple<_RTy...> result;
|
std::tuple<_RTy...> result;
|
||||||
|
|
||||||
|
Callback<_RTy...> callback;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ResultStorage(std::size_t partitions, Callback<_RTy...> callback_)
|
||||||
|
: partitions_left(partitions), callback(callback_) { }
|
||||||
|
|
||||||
|
template<std::size_t Position, typename... Args>
|
||||||
|
void store_result(Args&&... args)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<ResultStorage> shared_result_t;
|
typedef std::shared_ptr<ResultStorage> shared_result_t;
|
||||||
@ -570,33 +577,31 @@ namespace detail
|
|||||||
static return_t create(_CTy&&... functionals)
|
static return_t create(_CTy&&... functionals)
|
||||||
{
|
{
|
||||||
// C++11 workaround for move semantics of non copyable types
|
// C++11 workaround for move semantics of non copyable types
|
||||||
|
// TODO Use the stack instead of heap variables.
|
||||||
auto shared_functionals = std::make_shared<std::tuple<_CTy...>>(
|
auto shared_functionals = std::make_shared<std::tuple<_CTy...>>(
|
||||||
std::make_tuple(std::forward<_CTy>(functionals)...)
|
std::make_tuple(std::forward<_CTy>(functionals)...)
|
||||||
);
|
);
|
||||||
|
|
||||||
return [=](_ATy&&... args) mutable
|
return [=](_ATy&&... args) mutable
|
||||||
{
|
{
|
||||||
auto shared_args = std::make_shared<std::tuple<_ATy...>>(std::make_tuple(std::forward<_ATy>(args)...));
|
// TODO Use the stack instead of heap variables.
|
||||||
|
auto shared_args =
|
||||||
|
std::make_shared<std::tuple<_ATy...>>(
|
||||||
|
std::make_tuple(std::forward<_ATy>(args)...)
|
||||||
|
);
|
||||||
|
|
||||||
// Fake continuable which wraps all continuables together
|
// Fake continuable which wraps all continuables together
|
||||||
return make_continuable([=](Callback<_RTy...>&& callback) mutable
|
return make_continuable([=](Callback<_RTy...>&& callback) mutable
|
||||||
{
|
{
|
||||||
shared_result_t result(new ResultStorage(sizeof...(_CTy)));
|
|
||||||
|
|
||||||
sequenced_invoke<
|
sequenced_invoke<
|
||||||
fu::sequence_of_t<
|
fu::sequence_of_t<
|
||||||
sizeof...(_CTy)
|
sizeof...(_CTy)
|
||||||
>
|
>
|
||||||
>::invoke(
|
>::invoke(
|
||||||
result,
|
std::make_shared<ResultStorage>(sizeof...(_CTy), callback),
|
||||||
std::move(*shared_args),
|
std::move(*shared_args),
|
||||||
std::move(*shared_functionals)
|
std::move(*shared_functionals)
|
||||||
);
|
);
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
++i;
|
|
||||||
|
|
||||||
std::cout << "hey all was called!" << std::endl;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user