15 #include "RConfigure.h" 19 #include <type_traits> 25 #if !defined(__ROOTCLING__) && !defined(G__DICTIONARY) 26 #error "Cannot use ROOT::Experimental::Async without defining R__USE_IMT." 33 namespace Experimental {
47 std::unique_ptr<TTaskGroup> fTg{
nullptr};
49 TFutureImpl(std::future<T> &&fut, std::unique_ptr<TTaskGroup> &&tg) : fStdFut(
std::move(fut))
74 bool valid()
const {
return fStdFut.valid(); };
78 namespace Experimental {
84 template <
class Function,
class... Args>
87 Async(Function &&f, Args &&... args);
90 TFuture(std::future<T> &&fut, std::unique_ptr<TTaskGroup> &&tg)
99 return this->fStdFut.get();
106 template <
class Function,
class... Args>
109 Async(Function &&f, Args &&... args);
112 TFuture(std::future<void> &&fut, std::unique_ptr<TTaskGroup> &&tg)
125 template <
typename T>
127 template <
class Function,
class... Args>
133 TFuture(std::future<T &> &&fut, std::unique_ptr<TTaskGroup> &&tg)
142 return this->fStdFut.get();
150 template <
class Function,
class... Args>
160 auto thisPt = std::make_shared<std::packaged_task<Ret_t()>>(std::bind(f, args...));
162 tg->Run([thisPt]() { (*thisPt)(); });
TFutureImpl(std::future< T > &&fut, std::unique_ptr< TTaskGroup > &&tg)
Namespace for new ROOT classes and functions.
TFuture< typename std::result_of< typename std::decay< Function >::type(typename std::decay< Args >::type...)>::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, std::unique_ptr< TTaskGroup > &&tg)
Double_t(* Function)(Double_t)
TFutureImpl(std::future< T > &&fut)
A class to manage the asynchronous execution of work items.
TFuture(std::future< T > &&fut)
TFutureImpl(TFutureImpl< T > &&other)
A TFuture class. It can wrap an std::future.
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN
Binding & operator=(OUT(*fun)(void))
TFutureImpl & operator=(std::future< T > &&other)