Fix thread synchronization bug + many more #8562
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The most important thing is in the 4th commit. Maybe on "normal" hardware it's not visible, but I have an older laptop (tried this from Win) and I can barely reach ~3 FPS. The problem is that the 3 threads are not synchronized correctly, and when user presses Esc on drawing window, the drawing thread is terminating and also stop reading from queues, leaving (at least one of) the other 2 threads hanging in put. Only way to stop is killing the process (Ctrl+ Break).
Now the program gracefully stops in both scenarios (tested with a movie file).
The patch also contains what I consider to be a (lame) workaround (gainarie) - which is opening the capture twice.
To be frank, I saw this as a preamble for a bigger thing: switching to multiprocessing. But besides another (worse) workaround (loading the network twice), the result was totally unexpected: ~2 FPS, so I dropped it. I created a separate PR (with no intention of merging it), just to be available to whomever would be interested: #8567.
I noticed that many files are duplicated under build/darknet/x64. Shouldn't that be cleaned up?