Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:42

0001 // @(#)root/thread:$Id$
0002 // Author: Danilo Piparo August 2017
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TTaskGroup
0013 #define ROOT_TTaskGroup
0014 
0015 #include <atomic>
0016 #include <memory>
0017 #include <functional>
0018 
0019 namespace ROOT {
0020 namespace Internal {
0021 class RTaskArenaWrapper;
0022 }
0023 
0024 namespace Experimental {
0025 
0026 class TTaskGroup {
0027    /**
0028    \class ROOT::Experimental::TTaskGroup
0029    \ingroup Parallelism
0030    \brief A class to manage the asynchronous execution of work items.
0031 
0032    A TTaskGroup represents concurrent execution of a group of tasks. Tasks may be dynamically added to the group as it
0033    is executing.
0034    */
0035 private:
0036    std::shared_ptr<ROOT::Internal::RTaskArenaWrapper> fTaskArenaW;
0037    void *fTaskContainer{nullptr};
0038    void ExecuteInIsolation(const std::function<void(void)> &operation);
0039 
0040 public:
0041    TTaskGroup();
0042    TTaskGroup(TTaskGroup &&other);
0043    TTaskGroup(const TTaskGroup &) = delete;
0044    TTaskGroup &operator=(TTaskGroup &&other);
0045    ~TTaskGroup();
0046 
0047    void Cancel();
0048    void Run(const std::function<void(void)> &closure);
0049    void Wait();
0050 };
0051 } // namespace Experimental
0052 } // namespace ROOT
0053 
0054 #endif