-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add wait_for_tasks()
#62
Conversation
I've tested and reviewed the code, and it functions flawlessly. I compiled the test suite with both Clang and GCC, using thread and address sanitizers. All test runs produced zero errors. The only thing I am concerned about is performance. Consider a scenario where all threads are awake, spinning in the inner loop ( I benchmarked the current master version and this pull request using the first two count primes benchmarks. The results were very similar. So I think it is acceptable because that case does not happen so often. |
@GabTux Awesome thanks for testing things out. Nice catch with the case of one long running task keeping the rest of the threads awake. Maybe we do need 2 counters after all; maybe with just different names. |
I re-named the counters to names I feel make their use more clear (and distinct). This helps make clear (in my opinion) why there are 2 counters instead of just one as GabTux noted in the comment on #62
wait_for_tasks()
wait_for_tasks()
Instead, re-use the pending_tasks counter, but change where we decrement the value
704c137
to
81d8484
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #62 +/- ##
==========================================
+ Coverage 98.07% 98.24% +0.16%
==========================================
Files 2 2
Lines 104 114 +10
==========================================
+ Hits 102 112 +10
Misses 2 2 ☔ View full report in Codecov by Sentry. |
This PR builds on top of #61 and adds a
wait_for_tasks()
functions.Fixes #23