@@ -117,15 +117,15 @@ auto build_event(int
117117// Multithreaded driver
118118// Each thread repeatedly grabs the next event number from an atomic counter
119119// -----------------------------------------------------------------------------
120- void run_simulation (int nevents,
121- int nthreads,
122- const std::shared_ptr<GLogger>& logs,
123- const std::shared_ptr<GLogger>& loge,
124- const std::shared_ptr<GLogger>& logt,
125- const std::unordered_map<std::string, std::shared_ptr<GDynamicDigitization>>& dynamicRoutinesMap,
126- GOptions* gopt ,
127- std::vector<std::unique_ptr<GEventDataCollection>>& runData,
128- std::mutex& runDataMtx) {
120+ void run_simulation (int nevents,
121+ int nthreads,
122+ const std::shared_ptr<GLogger>& logs,
123+ const std::shared_ptr<GLogger>& loge,
124+ const std::shared_ptr<GLogger>& logt,
125+ const std::unordered_map<std::string, std::shared_ptr<GDynamicDigitization>>& dynamicRoutinesMap,
126+ const std::vector<std::unordered_map<std::string, std::shared_ptr<GStreamer>>> streamers ,
127+ std::vector<std::unique_ptr<GEventDataCollection>>& runData,
128+ std::mutex& runDataMtx) {
129129 // thread-safe integer counter starts at 1.
130130 // fetch_add returns the old value *and* bumps.
131131 // Zero contention: each thread fetches the next free event number.
@@ -155,12 +155,11 @@ void run_simulation(int
155155 logs->info (0 , " worker " , tid, " started" );
156156
157157 int localCount = 0 ; // events built by *this* worker
158+ // get streamer for this thread
159+ const auto & streamersMap = streamers[tid]; // get the map of gstreamers for this thread
158160
159- auto gstreamer_defs = gstreamer::getGStreamerDefinition (gopt); // get the vector of GStreamerDefinition from options
160- const auto & streamers = gstreamer::gstreamersMap (gstreamer_defs, tid, gopt, logs ); // all gstreamers for this thread
161161
162162 while (true ) {
163-
164163 // repeatedly asks the shared atomic counter for “the next unclaimed event
165164 // number,” processes that event, stores the result, and goes back for more.
166165 // memory_order_relaxed: we only need *atomicity*, no ordering
@@ -200,17 +199,11 @@ void run_simulation(int
200199}
201200
202201
203- #include " TROOT.h"
204- #include " TSystem.h"
205202
206203// notice runData is not really used here, but we keep the code as reference on how to accumulate
207204// events in a thread-safe way into a shared vector.
208205int main (int argc, char * argv[]) {
209206
210- // Trigger interpreter and global dictionary setup
211- TClass::GetClass (" TObject" ); // this is a safe no-op that triggers interpreter init
212- gSystem ->Load (" libCore" ); // optional: explicitly load libraries
213-
214207 // runData holds the finished events. We store them as *unique_ptr* because
215208 // each event is owned by the container and *only* by the container (single
216209 // ownership → choose unique_ptr, not shared_ptr).
@@ -239,9 +232,12 @@ int main(int argc, char* argv[]) {
239232 constexpr int nevents = 200 ;
240233 constexpr int nthreads = 8 ;
241234
235+ auto gstreamer_defs = gstreamer::getGStreamerDefinition (gopts); // get the vector of GStreamerDefinition from options
236+ const auto & streamers= gstreamer::gstreamersMapVector (gstreamer_defs, nthreads, gopts, logs); // all gstreamers for this thread
237+
242238 run_simulation (nevents, nthreads, logs, loge, loge,
243239 dynRoutinesConstMap,
244- gopts ,
240+ streamers ,
245241 runData,
246242 runDataMtx);
247243
0 commit comments