diff --git a/include/Continuable.h b/include/Continuable.h index f350982..256ffcf 100644 --- a/include/Continuable.h +++ b/include/Continuable.h @@ -509,6 +509,26 @@ namespace detail Callback<_RTy...> callback; + std::mutex lock; + + template + struct result_store_sequencer; + + template + struct result_store_sequencer, Offset> + { + // Do nothing + inline static void store(std::tuple<_RTy...>& result) + { + } + + // Store the args in the result tuple + template + inline static void store(std::tuple<_RTy...>& result, Args&&... args) + { + } + }; + public: ResultStorage(std::size_t partitions, Callback<_RTy...> callback_) : partitions_left(partitions), callback(callback_) { } @@ -516,8 +536,21 @@ namespace detail template void store_result(Args&&... args) { + result_store_sequencer< + fu::sequence_of_t, + Position + >::store(result, std::forward(args)...); - } + // TODO Improve the lock here + std::lock_guard guard(lock); + { + // If all partitions have completed invoke the final callback. + if (--partitions_left == 0) + { + + } + } + } }; typedef std::shared_ptr shared_result_t;