stevan / promises-perl

An implementation of Promises in Perl
31 stars 29 forks source link

collect() eats 100% cpu when called without arguments #82

Closed ehuelsmann closed 5 years ago

ehuelsmann commented 5 years ago

While I do understand this isn't the intended use-case, this code triggered the above condition for me:

    collect(map { $_->validate() } @resources)
    ->then(sub { call_after_all_finished(); });

Where each validate() method returns a promise, but @resources was empty. I'm not interested in the values to which the promises resolve; basically, they're only used to wait for all actions to be completed before going to the final step.

ehuelsmann commented 5 years ago

If that's appreciated, I could submit a PR where collect() returns a resolved promise when called without arguments.

yanick commented 5 years ago

[PRs welcome] Absolutely!

ehuelsmann commented 5 years ago

thanks for the fix! I couldn't have solved it more elegantly!

yanick commented 5 years ago

New release should be out in a matter of hours!