>
> So the question is, which one of equal variants is better and more simple?
>
While it is not proven that using fieldhash actively prevents circular
references in the Mojo::IOLoop::Delay scenario, it does help avoiding false
positives with Devel::Cycle.
perl -Ilib -Mojo -MDevel::Cycle -E 'my $ua = Mojo::UserAgent->new;
Mojo::IOLoop->delay(sub { my $d = shift; $ua->get("mojolicio.us" =>
$d->begin); find_cycle $d }, sub { $ua->get("mojolicio.us" => shift->begin)
}, sub {})->wait'
Without fieldhash you would see a circular reference here.
Cycle (1):
$Mojo::IOLoop::Delay::A->{'remaining'} => \@B
$B->[0] => \&C
$C variable $ua => \$D
$$D => \%Mojo::UserAgent::E
$Mojo::UserAgent::E->{'connections'} => \%F
$F->{'c92d527d9db95e50179b96ba1d71d8dd'} => \%G
$G->{'cb'} => \&H
$H variable $self => \$I
$$I => \%Mojo::IOLoop::Delay::A
But a totally harmless one, because it gets automatically resolved once the
callback has been consumed. I'd rather not have these false positives in
Devel::Cycle output, and therefore consider the current solution superior.
--
sebastian
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.