Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:55

0001 #ifndef FWCore_Concurrency_syncWait_h
0002 #define FWCore_Concurrency_syncWait_h
0003 //
0004 //  syncWait.h
0005 //
0006 //  Created by Chris Jones on 2/24/21.
0007 //
0008 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0009 #include "FWCore/Concurrency/interface/FinalWaitingTask.h"
0010 #include "oneapi/tbb/task_group.h"
0011 #include <exception>
0012 
0013 namespace edm {
0014   template <typename F>
0015   [[nodiscard]] std::exception_ptr syncWait(F&& iFunc) {
0016     std::exception_ptr exceptPtr{};
0017     oneapi::tbb::task_group group;
0018     FinalWaitingTask last{group};
0019     group.run([&]() { iFunc(WaitingTaskHolder(group, &last)); });  //group.run
0020 
0021     return last.waitNoThrow();
0022   }
0023 }  // namespace edm
0024 #endif /* FWCore_Concurrency_syncWait_h */