OnlineMonitor: Resolving Issues with Threading
This MR contains some fixups to !650 (merged) since @pschutze and me experienced issues with some modules when attempting do online monitoring, manifesting itself in seemingly random crashes deep within different parts of ROOT, changing whenever restarting.
This was traced back to be a threading issue, so this MR implements the following changes:
- The
TApplication
is created on the main thread - this removes the random crashes but leaves the spawned thread with an empty ROOT directory - Passing the
gDirectory
ti the spawned GUI thread andcd()
ing into it explicitly restores access to the histograms - The
gui_running
is now astd::atomic<bool>
to be thread-safe - An additional
gui_ready
atomic bool blocks the main threadinitialize()
method until the GUI has been properly initialized. This removes possible race conditions between histogram creating/filling in other modules and the booking and access thereof from the GUI thread.
@aloeschc would you be so kind to look at this and test this since it touches your work?