1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#ifndef FWCore_Concurrency_syncWait_h
#define FWCore_Concurrency_syncWait_h
//
// syncWait.h
//
// Created by Chris Jones on 2/24/21.
//
#include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
#include "FWCore/Concurrency/interface/FinalWaitingTask.h"
#include "oneapi/tbb/task_group.h"
#include <exception>
namespace edm {
template <typename F>
[[nodiscard]] std::exception_ptr syncWait(F&& iFunc) {
std::exception_ptr exceptPtr{};
oneapi::tbb::task_group group;
FinalWaitingTask last{group};
group.run([&]() { iFunc(WaitingTaskHolder(group, &last)); }); //group.run
return last.waitNoThrow();
}
} // namespace edm
#endif /* FWCore_Concurrency_syncWait_h */
|