Skip to content

Commit

Permalink
added another timer example
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 21, 2012
1 parent 390d5ff commit e0360e0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Mojo/Reactor.pm
Expand Up @@ -49,7 +49,8 @@ sub one_tick {
my $self = shift;

# Remember state
(my $state, $self->{running}) = ($self->{running}, 1);
my $running = $self->{running};
$self->{running} = 1;

# I/O
my $poll = $self->_poll;
Expand Down Expand Up @@ -79,7 +80,7 @@ sub one_tick {
}

# Restore state if necessary
$self->{running} = $state if $self->{running};
$self->{running} = $running if $self->{running};
}

sub recurring { shift->_timer(pop, after => pop, recurring => time) }
Expand Down Expand Up @@ -244,6 +245,9 @@ the reactor, so you need to be careful.
Create a new recurring timer, invoking the callback repeatedly after a given
amount of time in seconds.
# Invoke as soon as possible
$reactor->recurring(0 => sub { say 'Reactor tick.' });
=head2 C<start>
$reactor->start;
Expand Down

0 comments on commit e0360e0

Please sign in to comment.