@@ -684,6 +684,23 @@ sub plan_search ($$$$) {
$events ||= [ ];
+ my $share_compat_ok = sub {
+ my ($eshare) = @_;
+ $dbgprint->("PLAN LOOP SHARE-COMPAT-OK ".
+ "type $eshare->{Type} vs. ".
+ ($req->{Shared} // '<undef>')." ".
+ "wear $eshare->{Wear} ".
+ "shares $eshare->{Shares} vs. ".
+ ($req->{SharedMaxTasks}//'<undef>'));
+ return 0 unless defined $req->{Shared};
+ return 0 unless $req->{Shared} eq $eshare->{Type};
+ my $wear= $eshare->{Wear}+1;
+ return 0 if $wear > $req->{SharedMaxWear};
+ return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
+ $dbgprint->("PLAN LOOP SHARE-COMPAT-OK Y");
+ return 1;
+ };
+
# can we do $req at $try_time ? If not, when later can we ?
PERIOD:
foreach (my $ix=0; $ix<@$events; $ix++) {
@@ -698,23 +715,6 @@ 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) = @_;
- $dbgprint->("PLAN LOOP SHARE-COMPAT-OK ".
- "type $eshare->{Type} vs. ".
- ($req->{Shared} // '<undef>')." ".
- "wear $eshare->{Wear} ".
- "shares $eshare->{Shares} vs. ".
- ($req->{SharedMaxTasks}//'<undef>'));
- return 0 unless defined $req->{Shared};
- return 0 unless $req->{Shared} eq $eshare->{Type};
- my $wear= $eshare->{Wear}+1;
- return 0 if $wear > $req->{SharedMaxWear};
- return 0 if $eshare->{Shares} != $req->{SharedMaxTasks};
- $dbgprint->("PLAN LOOP SHARE-COMPAT-OK Y");
- 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