Can a single root macro be run multiple times simulatenously?

Hi everyone,
I have a question (probably more related to the basics of C/C++).

I have a root macro that takes in a file, processes it, and saves the output in a file; the input and output files are indexed(so no overwriting).
Once I execute the root macro to take input input_file_1 and output in output_1 and it is still running, can I -e-execute that macro with a different input(input_file_1) and corresponding out file(output_file_2)?

Thanks a lot !

From what you describe you can launch multiple process either running the macro with the different argument without any problem.

You can also most likely (if your macro/function is thread safe) do it with a single process and multiple threads, for example something like:

ROOT::EnableThreadSafetly()
std::vector<std::thread> threads;
for( loop over the inputs ) {
   threads.emplace_back( name_of_function, value_arguments);
}
for (auto& t : threads)
  t.join();
1 Like

Thank You @pcanal

An alternative is to use bash for the multiple processes.

root -l -b -q -e '.L myscript.cpp+'

root -l -b -q myscript.cpp+(arg1) & root -l -b -q myscript.cpp+(arg2) & ...
1 Like