Created
November 15, 2013 03:05
-
-
Save olegwtf/7478457 to your computer and use it in GitHub Desktop.
Mojolicious and AnyEvent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use Mojo::Reactor::EV; | |
use v5.10; | |
BEGIN { | |
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::EV'; | |
$ENV{MOJO_IOLOOP_DEBUG} = 1; | |
} | |
use Mojo::IOLoop; | |
use Mojo::UserAgent; | |
use AnyEvent::HTTP; | |
use URI; | |
my $ua = Mojo::UserAgent->new(); | |
for my $url (qw/google.ru mail.ru yandex.ru rambler.ru 2gis.ru/) { | |
http_get "http://$url/", sub { | |
say "AE: ", $url; | |
}; | |
$ua->get("http://$url", sub { | |
say "Mojo: ", $url; | |
}); | |
} | |
Mojo::IOLoop->start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment