Permalink
Browse files

remove run_loop from Server implementations. Use register_service if …

…you don't want main event loop run
  • Loading branch information...
miyagawa committed Oct 3, 2009
1 parent 17355b7 commit 41efb8b463635d1316da06b943599129a75142f5
View
@@ -53,7 +53,6 @@ sub run_one {
my $handler = Plack::Util::load_psgi $app;
my $server = Plack::Loader->load($server_class, port => $port);
$server->run($handler);
- $server->run_loop if $server->can('run_loop'); # run event loop
}
}
View
@@ -37,6 +37,5 @@
my $handler = Plack::Util::load_psgi($opts{app});
my $impl = Plack::Loader->load('FCGI');
$impl->run($handler);
- $impl->run_loop if $impl->can('run_loop'); # run event loop
die 'should not reach here';
}
@@ -30,7 +30,7 @@ sub new {
$self;
}
-sub run {
+sub register_service {
my($self, $app) = @_;
my $guard = tcp_server $self->{host}, $self->{port}, sub {
@@ -170,7 +170,9 @@ sub _response_handler {
};
}
-sub run_loop {
+sub run {
+ my $self = shift;
+ $self->register_service(@_);
AnyEvent->condvar->recv;
}
@@ -41,7 +41,7 @@ sub new {
$self;
}
-sub run {
+sub register_service {
my ($self, $app) = @_;
my $ssock = IO::Socket::INET->new(
@@ -90,7 +90,9 @@ sub run {
});
}
-sub run_loop {
+sub run {
+ my $self = shift;
+ $self->register_service(@_);
if ($HasAIO) {
Danga::Socket->AddOtherFds(IO::AIO::poll_fileno() => \&IO::AIO::poll_cb);
}
@@ -19,7 +19,7 @@ sub new {
$self;
}
-sub run {
+sub register_service {
my ($self, $app) = @_;
my $sock = IO::Socket::INET->new(
LocalAddr => $self->{host},
@@ -51,7 +51,9 @@ sub run {
return $self;
}
-sub run_loop {
+sub run {
+ my $self = shift;
+ $self->register_service(@_);
EV::loop;
}
@@ -10,7 +10,7 @@ sub new {
bless \%args, $class;
}
-sub run {
+sub register_service {
my($self, $app) = @_;
$self->{guard} = reverse_http $self->{host}, $self->{token}, sub {
my $req = shift;
@@ -30,7 +30,9 @@ sub run {
};
}
-sub run_loop {
+sub run {
+ my $self = shift;
+ $self->register_service(@_);
AE::cv->recv;
}
View
@@ -31,7 +31,6 @@ sub test_psgi {
my $port = shift;
my $server = Plack::Loader->auto(port => $port, host => ($args{host} || '127.0.0.1'));
$server->run($app);
- $server->run_loop if $server->can('run_loop');
},
);
}
View
@@ -518,7 +518,6 @@ sub run_server_tests {
my($port, $app) = @_;
my $server = Plack::Loader->load($server_class, port => $port, host => "127.0.0.1");
$server->run($app);
- $server->run_loop if $server->can('run_loop');
}
}
View
@@ -42,7 +42,6 @@ sub run_one {
my $port = shift;
my $server = Plack::Server::FCGI::EV->new(host => '127.0.0.1', port => $port);
$server->run($handler);
- $server->run_loop;
},
port => $fcgi_port
);

0 comments on commit 41efb8b

Please sign in to comment.