Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Async-Defer CPAN distribution.

Report information
The Basics
Id: 78179
Status: resolved
Priority: 0/
Queue: Async-Defer

People
Owner: Nobody in particular
Requestors: TOSHIOITO [...] cpan.org
Cc: powerman [...] powerman.name
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.9.0
Fixed in: (no value)



CC: powerman [...] powerman.name
Subject: A wishlist of some API changes in Async::Defer
Here is my wishlist of API changes that may improve the usability of this module. 1. I wish do() method accepted multiple tasks as a list parameter, like $d->do(@tasks); which is just a short-hand of calling do() multiple times. 2. I wish run(), do(), if() and other statement methods returned the Async::Defer object. That way, we can use method chaining to describe an async program like:: my $d = Async::Defer->new()->do(sub { ... })->if(sub { ... })->do(sub { ... })->else()->do(sub { ... })->end_if()->do(sub { })->run(); 3. I wish run() method accepted a coderef as well as a parent defer, because I want to treat $d->run() as just another async function that calls the user-given callback when it's done. I think $d->run($coderef) might as well be equivalent to:: my $callback_defer = Async::Defer->new(); $callback_defer->do(sub { my $this = shift; $coderef->(@_); $this->done }); $d->run($callback_defer); The above wishlist is just small changes in API spec, but I believe it significantly helps reduce redundant codes such as multiple occurrence of $d->... and ephemeral named variables like "my $callback_defer". ----- Toshio ITO debug.ito@gmail.com