-
Notifications
You must be signed in to change notification settings - Fork 254
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
#.find #273
Comments
check how |
... not sure if it's actually being lazy though ... there is support to |
I've made an implementation. It's a bit hacky and would be happy to get some feedback. Before i make a pull request, i'd like to mention that What do you think about the following names: block = lambda { |e| if e > 2; e; end }
Parallel.first_result([1,2,3], &block)
Parallel.find_first_result([1,2,3], &block)
Parallel.first_done([1,2,3], &block) |
In addtion to Parallel::Kill and Parallel::Break, a new Exception class named Parallel::Return allows raising an Exception which wraps a result value. That wrapped result will be unwrapped. When a method expects a single result, the option `:return_one` must be provided, because a given Enumeration might not contain a matching element or result.
In addtion to Parallel::Kill and Parallel::Break, a new Exception class named Parallel::Return allows raising an Exception which wraps a result value. That wrapped result will be unwrapped. When a method expects a single result, the option `:return_one` must be provided, because a given Enumeration might not contain a matching element or result.
usually this is done with |
I don't want to start a dicussion, but... :) I have some thoughts on your suggested interface
|
|
... I guess the |
|
find_result sounds the best to me 👍 |
... but breaking with a value could also be simple |
I got a expensive calculation and i want to kill all childs once one of them delivers a result:
Use case is solving a proof of work. One of the 16 processes will be the fastest and only one solution is needed. There seams to be no way to this or is ?
The text was updated successfully, but these errors were encountered: