|
6 | 6 | #include "glogger.h" |
7 | 7 | #include "event/gEventDataCollection.h" |
8 | 8 | #include "gdynamicdigitizationConventions.h" |
| 9 | +#include "gthreads.h" |
9 | 10 |
|
10 | 11 | // geant4 |
11 | 12 | #include "G4RunManagerFactory.hh" |
12 | 13 | #include "QBBC.hh" |
13 | 14 |
|
14 | 15 | // c++ |
15 | 16 | #include <atomic> // std::atomic<T>: lock-free, thread-safe integers, flags… |
16 | | -//#include <jthread> // C++20 std::jthread: joins automatically in its dtor (destructor) |
17 | | -#include <thread> // replaces <jthread> until C++20 is widely available. remove this line when <jthread> is available. |
18 | 17 | #include <vector> |
19 | 18 | #include <memory> // smart pointers |
20 | 19 |
|
21 | | -// TODO: remove when C++20 is widely available |
22 | | -// ===== portable jthread-like wrapper ========================================= |
23 | | -// If real std::jthread is present, use it. Otherwise, define a minimal shim |
24 | | -// that joins in the destructor (no stop_token support, but good enough here). |
25 | | -#if defined(__cpp_lib_jthread) // header exists |
26 | | -#include <jthread> |
27 | | -using jthread_alias = std::jthread; |
28 | | -#else |
29 | | -// join: pause right here until that thread is finished. |
30 | | -class jthread_alias : public std::thread { |
31 | | -public: |
32 | | - using std::thread::thread; // inherit all ctors |
33 | | - ~jthread_alias() { if (joinable()) join(); } |
34 | | - jthread_alias(jthread_alias&&) noexcept = default; |
35 | | - jthread_alias& operator=(jthread_alias&&) noexcept = default; |
36 | | - // no copy |
37 | | - jthread_alias(const jthread_alias&) = delete; |
38 | | - jthread_alias& operator=(const jthread_alias&) = delete; |
39 | | -}; |
40 | | -#endif |
41 | | - |
42 | | -const std::string plugin_name = "test_gdynamic_plugin"; |
43 | 20 |
|
44 | 21 | auto run_simulation_in_threads(int nevents, |
45 | 22 | int nthreads, |
|
0 commit comments