CC: | powerman [...] powerman.name |
Subject: | Async::Defer rejects Defer children even when they are its subclass |
In do() and _do_batch() methods of Async::Defer, ref($task) is
directly compared against __PACKAGE__. Because of this, it rejects any
non-Async::Defer object for a child defer, even if the child directly
inherits Async::Defer.
As far as I read the source code, the only requirement the child must
satisfy is that it implements run() and clone() methods properly.
Therefore, I would appreciate it greatly if you change the argument
check from
given (ref $task) {
...
when (__PACKAGE__) { ... }
to something like
if(blessed($task) && $task->can('run') && $task->can('clone')) { ... }
Background:
Since an Async::Defer object cannot be run multiple times
simultaneously (I think it's OK as a module), I'm writing a subclass
of Async::Defer that automatically clones itself before running. It
also manages a built-in job queue to control the maximum number of
active instances.
I call it Async::Defer::Queue. It is not on CPAN (yet), but is on
Github https://github.com/debug-ito/Async-Defer-Queue
However, because of the argument check described above,
Async::Defer::Queue cannot be nested. Of course, overriding do() and
_do_batch() method may resolve the problem, but that approach is ugly
and a bit inefficient.
p.s.
I put your personal email address to CC in this bug report, in case
you don't pay attention to RT CPAN. I'm sorry if that was redundant.
-----
Toshio ITO
debug.ito@gmail.com