-
-
Notifications
You must be signed in to change notification settings - Fork 97
Add Async::Waiter #174
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 Async::Waiter #174
Conversation
@@ -1,17 +1,17 @@ | |||
# frozen_string_literal: true | |||
|
|||
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com> | |||
# | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you say if I start slowly introducing Rubocop?
I've already tried, got about 7.5k(!) issues, .rubocop_todo.yml was about 700 lines long.
I could start with simple cases likes this, missing newlines at the end of files or enforcing tabs for indentation(no need to fix, code is already properly formatted afair) branch
In all my projects I use Rubocop with almost default config (with rubocop-rake, rubocop-rspec, rubocop-performance where applicable) in combination with overcommit
to prevent bad code from being committed.
I know many cops are controversial, so it will be up to you whether to use them or not. But I believe autoformatting and some other basic things is a must have. To me working without rubocop is like working with only one hand and only one half of the brain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, I misread that as 75k issues lol.
When I tried RuboCop a while ago, IIRC it did not support tabs for indentation.
However, I believe that changed recently.
I'd be okay with introducing RuboCop but it would probably need to be the opposite way for me personally, it would need to disable every rule by default and we selectively enable ones that make sense. It would probably just be a small subset and if I did go in that direction I'd want to replicate it to other projects too.
|
||
require 'async/clock' | ||
require 'async/rspec' | ||
require 'async/semaphore' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about zeitwerk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Autoload is broken on Ruby with the fiber scheduler so it's a no go for now, but maybe later?
wait_for(n).first.map(&:wait) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment about Rubocop
This looks good to me - I like using a sub-class since you need to opt into it - there is extra overhead. It will require people know ahead of time they want to wait on a subset of items. Is there any other design we should consider? I wonder if it's worth looking at how other implementations work and how they handle this particular overhead. |
From #62:
Does the current implementation enable this feature? Since |
@bruno- Waiter passes all tests written for Barrier. At least for the case when all task are being awaited. For the case when N tasks are being awainted I decided that it's better when all coroutines waiting for a waiter get same N first results |
Closing in favour of #189 as discussed. |
WIP
As discussed here I introduce a new class called
Waiter
which can be a drop-in replacementBarrier
. The only difference is that it can await for first N tasks.Once and if the approach is approved I'll add more specific tests
Questions:
Even though the tasks with raises have eventually been awaited, I still see warnings in the logs:
Note: I'm leaving on vacation on August 2, the day after tomorrow and won't be able to code till August 9.
Types of Changes
Testing