Conversation
Any ProgressBar instantiated while another is active will not be shown.
|
946f1ce echoes discussion in #263. Historically a |
|
Fixes the |
OK, I guess there's quite a few edge cases to consider here. I'd only considered the case of nested ProgressBars, or at least ProgressBars instantiated sequentially within a single thread. The current safeguard should cater for most cases since even in a multi-threading context, the classes handling the tasks are instantiated within the main thread prior to launching the worker threads, so as long as things happen in the right order, the first to claim the ProgressBar gets to display it. I should also point out that the LogLevel latch is still effective in silencing unwanted progress messages if required, so that's always an option. Where things might fall over is in a context where the top-level multi-threaded operation does not itself instantiate a ProgressBar at all, but invokes multiple tasks that do instantiate their own ProgressBar. In that case, the terminal won't have been claimed first, and we end up with a race condition to claim it. But even in theory, if this was to work we would end up with multiple threads each competing to update the terminal with presumably the same progress message and different percentages - which I reckon is a situation we should be avoiding. One additional safeguard we could put in there is to add a check at this line to ensure that the thread ID is that of the main thread. We'd have the original main thread ID stored in a global static variable within the App::init() call, and then simply check that |
|
I suggest we merge this PR to ensure more or less correct behaviour on |
|
That last commit fixes issues that @maxpietsch pointed out to me. Should be good now... |
Closes #1700
I think this should do it.... The first commit here is the actual fix (silly mistake on my part). The second commit cleans up the implementation a bit (better encapsulation, but really mostly cosmetic). The last commit actively prevents a ProgressBar from displaying if another is already active - which should mean there is no need to use a loglevel latch to keep nested ProgressBars quiet...