SVN: toys/rsget.pl/RSGet/Main.pm

sparky sparky at pld-linux.org
Sun Nov 1 02:12:26 CET 2009


Author: sparky
Date: Sun Nov  1 02:12:25 2009
New Revision: 10915

Modified:
   toys/rsget.pl/RSGet/Main.pm
Log:
- iteration body separated from main loop function


Modified: toys/rsget.pl/RSGet/Main.pm
==============================================================================
--- toys/rsget.pl/RSGet/Main.pm	(original)
+++ toys/rsget.pl/RSGet/Main.pm	Sun Nov  1 02:12:25 2009
@@ -250,37 +250,47 @@
 	}
 }
 
+sub iteration_short
+{
+	if ( RSGet::Curl::need_run() ) {
+		RSGet::Curl::maybe_abort();
+		foreach ( 0..4 ) {
+			RSGet::Curl::perform();
+			Time::HiRes::sleep(0.050);
+		}
+	} else {
+		Time::HiRes::sleep(0.250);
+	}
+	RSGet::Curl::update_status();
+	RSGet::Line::update();
+	$http->perform() if $http;
+}
+
+sub iteration_long
+{
+	RSGet::Wait::wait_update();
+	RSGet::MortalObject::update();
+	RSGet::Captcha::captcha_update();
+
+	my $getlist = RSGet::FileList::readlist();
+	return unless $getlist;
+
+	RSGet::Dispatch::process( $getlist );
+	RSGet::ListManager::autoadd( $getlist );
+}
+
 sub loop
 {
 	# main loop
 	my $lasttime = 0;
 	for (;;) {
-		if ( RSGet::Curl::need_run() ) {
-			RSGet::Curl::maybe_abort();
-			foreach ( 0..4 ) {
-				RSGet::Curl::perform();
-				Time::HiRes::sleep(0.050);
-			}
-		} else {
-			Time::HiRes::sleep(0.250);
-		}
-		RSGet::Curl::update_status();
-		RSGet::Line::update();
-		$http->perform() if $http;
+		iteration_short();
 
 		my $time = time;
 		next if $time == $lasttime;
 		$lasttime = $time;
-	
-		RSGet::Wait::wait_update();
-		RSGet::MortalObject::update();
-		RSGet::Captcha::captcha_update();
-
-		my $getlist = RSGet::FileList::readlist();
-		if ( $getlist ) {
-			my $allchk = RSGet::Dispatch::process( $getlist );
-			RSGet::ListManager::autoadd( $getlist );
-		}
+
+		iteration_long();
 	}
 }
 


More information about the pld-cvs-commit mailing list