Skip to content

Rewrite one :discard on queue overflow test for robustness #208

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

Merged
merged 2 commits into from
Dec 13, 2014

Conversation

rkday
Copy link
Contributor

@rkday rkday commented Dec 13, 2014

How about this as a different approach to 6af1316 ? The basic idea is that you take a lock, then inject enough tasks waiting on that lock to fill up all the threads and the queue. Then you inject more tasks which should never run, unlock the lock, and shutdown the executor so that all threads run to completion and your results are predictable.

It passes UT for me, and I think this is a robust approach, but the proof of the pudding will be in the eating. If you agree witth the approach, I can definitely reuse it for the other :discard tests, and maybe some others.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) when pulling 92073c1 on rkday:queue_overflow_uts into 5929b46 on ruby-concurrency:master.

@rkday
Copy link
Contributor Author

rkday commented Dec 13, 2014

Okay, clearly not quite robust enough yet.

@rkday
Copy link
Contributor Author

rkday commented Dec 13, 2014

Ah, because there's no guarantee that my tasks are being moved off the queue onto a worker thread before I put more tasks on the queue. Fixing that now.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) when pulling 445146a on rkday:queue_overflow_uts into 5929b46 on ruby-concurrency:master.

@pitr-ch
Copy link
Member

pitr-ch commented Dec 13, 2014

@rkday This is great, Thanks! It may be better to replace Mutex with Event though where the threads can Event#wait and be suspended.

@jdantonio
Copy link
Member

Awesome! Thank you!

jdantonio added a commit that referenced this pull request Dec 13, 2014
Rewrite one :discard on queue overflow test for robustness
@jdantonio jdantonio merged commit 40d13e5 into ruby-concurrency:master Dec 13, 2014
@jdantonio jdantonio removed the unknown label Dec 13, 2014
@rkday
Copy link
Contributor Author

rkday commented Dec 13, 2014

@pitr-ch, thanks! I hadn't come across Concurrent::Event yet but it looks useful - I've switched to it in #211 .

@jdantonio
Copy link
Member

@rkday Concurrent::Event is a trow-back to the days of yore when I worked on banking systems using MS Visual C++. I'm surprised more languages today don't have something like it, but I'm glad people find our version useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants