15#include "RConfigure.h"
26#if !defined(__ROOTCLING__) && !defined(G__DICTIONARY)
27#error "Cannot use ROOT::Experimental::Async without defining R__USE_IMT."
34namespace Experimental {
48 std::unique_ptr<TTaskGroup>
fTg{
nullptr};
79namespace Experimental {
85 template <
class Function,
class... Args>
87 ROOT::TypeTraits::InvokeResult_t<typename std::decay<Function>::type,
typename std::decay<Args>::type...>>
91 TFuture(std::future<T> &&fut, std::unique_ptr<TTaskGroup> &&tg)
92 :
ROOT::Detail::
TFutureImpl<T>(std::forward<std::future<T>>(fut), std::move(tg)){};
107 template <
class Function,
class... Args>
109 ROOT::TypeTraits::InvokeResult_t<typename std::decay<Function>::type,
typename std::decay<Args>::type...>>
113 TFuture(std::future<void> &&fut, std::unique_ptr<TTaskGroup> &&tg)
114 :
ROOT::Detail::
TFutureImpl<void>(std::forward<std::future<void>>(fut), std::move(tg)){};
117 TFuture(std::future<void> &&fut) :
ROOT::Detail::
TFutureImpl<void>(std::forward<std::future<void>>(fut)){};
128 template <
class Function,
class... Args>
130 ROOT::TypeTraits::InvokeResult_t<typename std::decay<Function>::type,
typename std::decay<Args>::type...>>
134 TFuture(std::future<T &> &&fut, std::unique_ptr<TTaskGroup> &&tg)
135 :
ROOT::Detail::TFutureImpl<
T &>(std::
forward<std::future<
T &>>(fut), std::move(tg)){};
138 TFuture(std::future<T &> &&fut) :
ROOT::Detail::TFutureImpl<
T &>(std::
forward<std::future<
T &>>(fut)){};
143 return this->fStdFut.get();
151template <
class Function,
class... Args>
152TFuture<ROOT::TypeTraits::InvokeResult_t<typename std::decay<Function>::type,
typename std::decay<Args>::type...>>
156 using Ret_t = ROOT::TypeTraits::InvokeResult_t<std::decay_t<Function>, std::decay_t<Args>...>;
158 auto thisPt = std::make_shared<std::packaged_task<Ret_t()>>(std::bind(
f, args...));
160 tg->Run([thisPt]() { (*thisPt)(); });
Double_t(* Function)(Double_t)
TFutureImpl(std::future< T > &&fut, std::unique_ptr< TTaskGroup > &&tg)
friend class Experimental::TFuture
TFutureImpl< T > & operator=(TFutureImpl< T > &other)=delete
TFutureImpl & operator=(std::future< T > &&other)
TFutureImpl(const TFutureImpl< T > &other)=delete
TFutureImpl< T > & operator=(TFutureImpl< T > &&other)=default
TFutureImpl(TFutureImpl< T > &&other)
TFutureImpl(std::future< T > &&fut)
std::unique_ptr< TTaskGroup > fTg
A TFuture class. It can wrap an std::future.
friend TFuture< ROOT::TypeTraits::InvokeResult_t< typename std::decay< Function >::type, typename std::decay< Args >::type... > > Async(Function &&f, Args &&...args)
Runs a function asynchronously potentially in a new thread and returns a ROOT TFuture that will hold ...
TFuture(std::future< T > &&fut)
TFuture(std::future< T > &&fut, std::unique_ptr< TTaskGroup > &&tg)
A class to manage the asynchronous execution of work items.
TFuture< ROOT::TypeTraits::InvokeResult_t< typename std::decay< Function >::type, typename std::decay< Args >::type... > > Async(Function &&f, Args &&...args)
Runs a function asynchronously potentially in a new thread and returns a ROOT TFuture that will hold ...
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN