set random behavior after we parse the option, so this is actually more
random... problem noticed by naddy@
This commit is contained in:
parent
a8e8acea0d
commit
9a2f0331f4
@ -1,5 +1,5 @@
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: Heuristics.pm,v 1.1 2010/02/24 11:33:31 espie Exp $
|
||||
# $OpenBSD: Heuristics.pm,v 1.2 2010/03/01 18:11:11 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -29,12 +29,14 @@ my (%weight, %needed_by);
|
||||
|
||||
sub new
|
||||
{
|
||||
my ($class, $opt_r) = @_;
|
||||
if ($opt_r) {
|
||||
bless {}, "DPB::Heuristics::random";
|
||||
} else {
|
||||
bless {}, $class;
|
||||
}
|
||||
my ($class) = @_;
|
||||
bless {}, $class;
|
||||
}
|
||||
|
||||
sub random
|
||||
{
|
||||
my $self = shift;
|
||||
bless $self, "DPB::Heuristics::random";
|
||||
}
|
||||
|
||||
sub set_logger
|
||||
@ -376,7 +378,7 @@ my %any;
|
||||
sub compare
|
||||
{
|
||||
my ($self, $a, $b) = @_;
|
||||
return ($any{$a} //= random()) <=> ($any{$b} //= random());
|
||||
return ($any{$a} //= rand) <=> ($any{$b} //= rand);
|
||||
}
|
||||
|
||||
sub new_queue
|
||||
|
@ -1,7 +1,7 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
# ex:ts=8 sw=4:
|
||||
# $OpenBSD: dpb3,v 1.3 2010/02/27 08:30:01 espie Exp $
|
||||
# $OpenBSD: dpb3,v 1.4 2010/03/01 18:11:11 espie Exp $
|
||||
#
|
||||
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
@ -71,7 +71,7 @@ sub parse_build_file
|
||||
}
|
||||
|
||||
my $parsed = 0;
|
||||
my $heuristics = DPB::Heuristics->new($opt_r);
|
||||
my $heuristics = DPB::Heuristics->new;
|
||||
set_usage("dpb3 [-acertx] [-A arch] [-j N] [-P plist] [-h hosts] [-L lockdir] [-b log] ",
|
||||
"[-T timeout] [-m threshold] [path ...]");
|
||||
try {
|
||||
@ -97,6 +97,9 @@ getopts('acerh:txA:f:j:m:P:b:L:T:', {
|
||||
Usage($_);
|
||||
};
|
||||
|
||||
if ($opt_r) {
|
||||
$heuristics->random;
|
||||
}
|
||||
if ($parsed) {
|
||||
$heuristics->finished_parsing;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user