File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ where
230230 ) -> Option < ConstraintViolation > {
231231 let demand = self . get_demand ( activity_ctx. target ) ;
232232
233- let violation = if activity_ctx. target . retrieve_job ( ) . is_some_and ( |job| job . as_multi ( ) . is_some ( ) ) {
233+ let violation = if activity_ctx. target . has_parent_job ( ) {
234234 // NOTE multi job has dynamic demand which can go in another interval
235235 if self . can_handle_demand_on_intervals ( route_ctx, demand, Some ( activity_ctx. index ) ) {
236236 None
Original file line number Diff line number Diff line change @@ -197,6 +197,11 @@ impl Multi {
197197 single. dimens . get_value :: < JobLink , Weak < Multi > > ( ) . and_then ( |w| w. upgrade ( ) )
198198 }
199199
200+ /// Returns `true` if given single job is a child of multi job.
201+ pub ( crate ) fn is_child ( single : & Single ) -> bool {
202+ single. dimens . get_value :: < JobLink , Weak < Multi > > ( ) . is_some ( )
203+ }
204+
200205 /// Wraps given multi job into [`Arc`] adding reference to it from all sub-jobs.
201206 fn bind ( mut multi : Self ) -> Arc < Self > {
202207 Arc :: new_cyclic ( |weak_multi| {
Original file line number Diff line number Diff line change @@ -112,7 +112,18 @@ impl Activity {
112112
113113 /// Checks whether activity has given job.
114114 pub fn has_same_job ( & self , job : & Job ) -> bool {
115- self . retrieve_job ( ) . as_ref ( ) == Some ( job)
115+ match ( job, self . job . as_ref ( ) ) {
116+ ( Job :: Single ( left) , Some ( right) ) => Arc :: ptr_eq ( left, right) ,
117+ ( Job :: Multi ( multi) , Some ( single) ) => {
118+ Multi :: roots ( single) . is_some_and ( |single_parent| Arc :: ptr_eq ( multi, & single_parent) )
119+ }
120+ _ => false ,
121+ }
122+ }
123+
124+ /// Checks whether activity job has a parent multi job.
125+ pub fn has_parent_job ( & self ) -> bool {
126+ self . job . as_ref ( ) . map_or ( false , |single| Multi :: is_child ( single) )
116127 }
117128
118129 /// Returns job if activity has it.
You can’t perform that action at this time.
0 commit comments