[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[OSSTEST PATCH 30/82] plan_search: Break out $share_compat_ok



From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

No functional change.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/Executive.pm | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 4cd4aa50..e4bb0868 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -700,6 +700,20 @@ sub plan_search ($$$$) {
             # this period is entirely after the proposed slot;
             # so no need to check this or any later periods
 
+           my $share_compat_ok = sub {
+               my ($eshare) = @_;
+               return 0 unless defined $req->{Shared};
+               return 0 unless $req->{Shared} eq $eshare->{Type};
+               if (defined $share_wear) {
+                   $share_wear++ if $startevt->{Type} eq 'Start';
+               } else {
+                   $share_wear= $eshare->{Wear}+1;
+               }
+               return 0 if $share_wear > $req->{SharedMaxWear};
+               return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
+               return 1;
+           };
+
            next PERIOD if $endevt->{Time} <= $try_time;
             # this period is entirely before the proposed slot;
             # it doesn't overlap, but must check subsequent periods
@@ -711,15 +725,7 @@ sub plan_search ($$$$) {
                my $eshare= $startevt->{Share};
                if ($eshare) {
                    $dbgprint->("PLAN LOOP   OVERLAP ESHARE");
-                   last CHECK unless defined $req->{Shared};
-                   last CHECK unless $req->{Shared} eq $eshare->{Type};
-                   if (defined $share_wear) {
-                       $share_wear++ if $startevt->{Type} eq 'Start';
-                   } else {
-                       $share_wear= $eshare->{Wear}+1;
-                   }
-                   last CHECK if $share_wear > $req->{SharedMaxWear};
-                   last CHECK if $eshare->{Shares} != $req->{SharedMaxTasks};
+                   last CHECK unless $share_compat_ok->($eshare);
                }
                # We have suitable availability for this period
                $dbgprint->("PLAN LOOP   OVERLAP AVAIL OK");
-- 
2.20.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.