summaryrefslogtreecommitdiff
path: root/lib/Loadbars/Main.pm
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2012-04-19 23:26:40 +0200
committerPaul Buetow <paul@buetow.org>2012-04-19 23:26:40 +0200
commit86c242f505280ee56f8c995bd8099bd4f026b6d3 (patch)
treebdb612e89264a6b8a44cd824d2da7a7b9f5ec2ef /lib/Loadbars/Main.pm
parenta152c0d0520dd00c863734a1720a528099779341 (diff)
refactoring
Diffstat (limited to 'lib/Loadbars/Main.pm')
-rw-r--r--lib/Loadbars/Main.pm67
1 files changed, 11 insertions, 56 deletions
diff --git a/lib/Loadbars/Main.pm b/lib/Loadbars/Main.pm
index 3a0239a..5b8f161 100644
--- a/lib/Loadbars/Main.pm
+++ b/lib/Loadbars/Main.pm
@@ -288,7 +288,7 @@ sub set_dimensions ($$) {
}
}
-sub main_loop ($@) {
+sub loop ($@) {
my ( $dispatch, @threads ) = @_;
my $num_stats = 1;
@@ -304,18 +304,18 @@ sub main_loop ($@) {
-resizeable => 1,
);
- my $fontbase = 'fonts/font.png';
+ my $font = do {
+ my $fontbase = 'fonts/font.png';
- if ( -f "./$fontbase" ) {
- $C{font} = "./$fontbase";
-
- }
- elsif ( -f "/usr/share/loadbars/$fontbase" ) {
- $C{font} = "/usr/share/loadbars/$fontbase";
- }
+ if ( -f "./$fontbase" ) {
+ "./$fontbase";
+ }
+ elsif ( -f "/usr/share/loadbars/$fontbase" ) {
+ "/usr/share/loadbars/$fontbase";
+ }
+ };
- say( "Foo:" . $C{font} );
- SDL::Font->new( $C{font} )->use();
+ SDL::Font->new($font)->use();
my $rects = {};
my %prev_stats;
@@ -884,49 +884,4 @@ sub main_loop ($@) {
exit Loadbars::Constants->SUCCESS;
}
-# Recursuve function
-sub get_cluster_hosts ($;$);
-
-sub get_cluster_hosts ($;$) {
- my ( $cluster, $recursion ) = @_;
-
- unless ( defined $recursion ) {
- $recursion = 1;
-
- }
- elsif ( $recursion > Loadbars::Constants->CSSH_MAX_RECURSION ) {
- error( "CSSH_MAX_RECURSION reached. Infinite circle loop in "
- . Loadbars::Constants->CSSH_CONFFILE
- . "?" );
- }
-
- open my $fh, Loadbars::Constants->CSSH_CONFFILE
- or error( "$!: " . Loadbars::Constants->CSSH_CONFFILE );
- my $hosts;
-
- while (<$fh>) {
- if (/^$cluster\s*(.*)/) {
- $hosts = $1;
- last;
- }
- }
-
- close $fh;
-
- unless ( defined $hosts ) {
- error( "No such cluster in "
- . Loadbars::Constants->CSSH_CONFFILE
- . ": $cluster" )
- unless defined $recursion;
-
- return ($cluster);
- }
-
- my @hosts;
- push @hosts, get_cluster_hosts $_, ( $recursion + 1 )
- for ( split /\s+/, $hosts );
-
- return @hosts;
-}
-
1;