SVN: toys/rsget.pl/RSGet: Main.pm Wait.pm
sparky
sparky at pld-linux.org
Thu Dec 23 02:27:20 CET 2010
Author: sparky
Date: Thu Dec 23 02:27:20 2010
New Revision: 12022
Modified:
toys/rsget.pl/RSGet/Main.pm
toys/rsget.pl/RSGet/Wait.pm
Log:
- use Time::HiRes for smoother wait progress indication
Modified: toys/rsget.pl/RSGet/Main.pm
==============================================================================
--- toys/rsget.pl/RSGet/Main.pm (original)
+++ toys/rsget.pl/RSGet/Main.pm Thu Dec 23 02:27:20 2010
@@ -339,6 +339,7 @@
Time::HiRes::sleep(0.250);
}
RSGet::Curl::update_status();
+ RSGet::Wait::wait_update();
RSGet::Line::update();
$http->perform() if $http;
}
@@ -346,7 +347,6 @@
sub iteration_long
{
RSGet::Dispatch::delay_check();
- RSGet::Wait::wait_update();
RSGet::MortalObject::update();
RSGet::Captcha::captcha_update();
Modified: toys/rsget.pl/RSGet/Wait.pm
==============================================================================
--- toys/rsget.pl/RSGet/Wait.pm (original)
+++ toys/rsget.pl/RSGet/Wait.pm Thu Dec 23 02:27:20 2010
@@ -8,6 +8,7 @@
use strict;
use warnings;
use RSGet::Tools;
+use Time::HiRes ();
set_rev qq$Id$;
my %waiting;
@@ -64,11 +65,11 @@
sub wait_update
{
- my $time = time;
+ my $time = Time::HiRes::time;
foreach my $id ( keys %waiting ) {
my $obj = $waiting{ $id };
- my $left = $obj->{wait_until} - $time;
+ my $left = $obj->{wait_until} - int $time;
if ( $left <= 0 ) {
delete $waiting{ $id };
$obj->print( $obj->{wait_msg} . "; done waiting" );
@@ -80,12 +81,12 @@
if ( $obj->{wait_until_should} ) {
$obj->print( sprintf "%s; should wait %s, retrying in %s",
$obj->{wait_msg},
- s2string( $obj->{wait_until_should} - $time),
+ s2string( $obj->{wait_until_should} - int $time),
s2string( $left ) );
} else {
$obj->print( $obj->{wait_msg} . "; waiting " . s2string( $left ) );
}
- $obj->linedata( prog => 1 - $left / $obj->{wait} );
+ $obj->linedata( prog => 1 - ( $obj->{wait_until} - $time ) / $obj->{wait} );
}
}
RSGet::Line::status( 'waiting' => scalar keys %waiting );
More information about the pld-cvs-commit
mailing list