Navigation Menu

Skip to content

Commit

Permalink
a little more consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 9, 2015
1 parent 67b2377 commit 7d5f180
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

5.72 2015-01-09
5.72 2015-01-10
- Improved Mojo::Reactor::EV to update the current time before starting a
timer.

Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/IOLoop.pm
Expand Up @@ -173,9 +173,10 @@ sub _accepting {
}

sub _id {
my $self = shift;
my $id;
do { $id = md5_sum 'c' . steady_time . rand 999 }
while $_[0]->{connections}{$id} || $_[0]->{acceptors}{$id};
while $self->{connections}{$id} || $self->{acceptors}{$id};
return $id;
}

Expand Down
8 changes: 6 additions & 2 deletions lib/Mojo/Reactor/Poll.pm
Expand Up @@ -111,8 +111,9 @@ sub watch {
}

sub _id {
my $self = shift;
my $id;
do { $id = md5_sum 't' . steady_time . rand 999 } while $_[0]->{timers}{$id};
do { $id = md5_sum 't' . steady_time . rand 999 } while $self->{timers}{$id};
return $id;
}

Expand All @@ -125,9 +126,12 @@ sub _sandbox {

sub _timer {
my ($self, $recurring, $after, $cb) = @_;
my $timer = $self->{timers}{my $id = $self->_id}

my $id = $self->_id;
my $timer = $self->{timers}{$id}
= {cb => $cb, after => $after, time => steady_time + $after};
$timer->{recurring} = $after if $recurring;

return $id;
}

Expand Down

0 comments on commit 7d5f180

Please sign in to comment.