Skip to content

Commit

Permalink
Use internal value instead of attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
judofyr committed Aug 4, 2011
1 parent f1fa911 commit c108fc8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/Mojolicious/Plugin/Parallol.pm
Expand Up @@ -7,7 +7,7 @@ sub register {

$app->hook(before_dispatch => sub {
my $self = shift;
$self->attr(paralloling => 0);
$self->{paralloling} = 0;
$self->attr('parallol_done' => sub {
sub { $self->render }
});
Expand All @@ -18,13 +18,11 @@ sub register {
my ($self, $callback) = @_;

$self->render_later;
$self->paralloling($self->paralloling + 1);
$self->{paralloling}++;

sub {
&$callback(@_);
$self->paralloling($self->paralloling - 1);

&{$self->parallol_done} if ($self->paralloling == 0);
&{$self->parallol_done}($self) if --$self->{paralloling} == 0;
}
}
);
Expand Down

0 comments on commit c108fc8

Please sign in to comment.