Permalink
Browse files

keep a number DISCOVER towels waiting

  • Loading branch information...
wertarbyte committed Feb 1, 2012
1 parent 0c88a3e commit dfc47c7e2448acde2be3c1dad0522e58271f1b29
Showing with 4 additions and 5 deletions.
  1. +4 −5 handtuch.pl
View
@@ -187,11 +187,7 @@ sub refreshTowels {
}
sub addTowel {
$towel{int(rand(0xFFFFFFFF))} = { state => "", packet => undef };
}
for (1..$n_towels) {
addTowel();
$towel{int(rand(0xFFFFFFFF))} = { state => "DISCOVER", packet => undef };
}
sub printTowelStatus {
@@ -211,5 +207,8 @@ sub printTowelStatus {
while (countTowels()<$n_towels) {
addTowel();
}
while ($n_towels < 0 && countTowels("")+countTowels("DISCOVER") < abs($n_towels)) {
addTowel();
}
printTowelStatus();
}

0 comments on commit dfc47c7

Please sign in to comment.