Skip to content

Commit

Permalink
Remove start() and stop()
Browse files Browse the repository at this point in the history
    If you want to start or stop the ioloop, then use the ioloop.
  • Loading branch information
Jan Henning Thorsen committed Aug 11, 2012
1 parent ebd0ced commit 91f0cb9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
15 changes: 0 additions & 15 deletions lib/Mojo/Redis.pm
Expand Up @@ -204,21 +204,6 @@ sub execute {
return $self;
}

sub start {
my ($self) = @_;

$self->ioloop->start;
return $self;
}

sub stop {
my ($self) = @_;

$self->ioloop->stop;
return $self;
}


sub _send_next_message {
my ($self) = @_;

Expand Down
10 changes: 5 additions & 5 deletions t/leak.t
Expand Up @@ -23,25 +23,25 @@ my $redis = Mojo::Redis->new(server => $ENV{REDIS_SERVER}, timeout => 5);
$redis->on_error(sub { });

no_leaks_ok {
$redis->ping(\&cb_ioloop_stop)->start;
$redis->ping(\&cb_ioloop_stop)->ioloop->start;
}
"ping";

no_leaks_ok {
$redis->execute("strange_command", \&cb_ioloop_stop)->start;
$redis->execute("strange_command", \&cb_ioloop_stop)->ioloop->start;
}
"error";

no_leaks_ok {
$redis->set(test => 'test_ok', \&cb_ioloop_stop)->start;
$redis->set(test => 'test_ok', \&cb_ioloop_stop)->ioloop->start;
}
"set";

no_leaks_ok {
$redis->get(test => \&cb_ioloop_stop)->start;
$redis->get(test => \&cb_ioloop_stop)->ioloop->start;
}
"get";

sub cb_ioloop_stop {
shift->stop;
shift->ioloop->stop;
}
4 changes: 2 additions & 2 deletions t/redis.t
Expand Up @@ -38,7 +38,7 @@ my $server = Mojo::IOLoop->server(

my $redis =
new_ok 'Mojo::Redis' => [server => "127.0.0.1:$port", timeout => 1];
Mojo::IOLoop->timer(5 => sub { $redis->stop }); #security valve
Mojo::IOLoop->timer(5 => sub { $redis->ioloop->stop }); #security valve


$redis->execute(
Expand All @@ -48,7 +48,7 @@ $redis->execute(
$r = $result;
&test2;
}
)->start;
)->ioloop->start;


is $sbuffer1, "*2\r\n\$3\r\nGET\r\n\$4\r\ntest\r\n", 'input command';
Expand Down
2 changes: 1 addition & 1 deletion t/redis_live.t
Expand Up @@ -88,5 +88,5 @@ $redis->set(test => 'ok')->get(
}
);

$redis->quit(sub { shift->stop; })->start;
$redis->quit(sub { shift->ioloop->stop; })->ioloop->start;

4 changes: 2 additions & 2 deletions t/redis_live_multi.t
Expand Up @@ -22,8 +22,8 @@ $redis->del('test')->multi->rpush(test => 'ok')->lrange(test => 0, -1)->exec(
sub {
my ($redis, $res) = @_;
$result = $res;
$redis->stop;
$redis->ioloop->stop;
}
)->start;
)->ioloop->start;

is_deeply $result, [1, ['ok']];

0 comments on commit 91f0cb9

Please sign in to comment.