@@ -21,6 +21,37 @@ extern "C" {
2121#include " planner.hpp"
2222
2323
24+ /* ***************************************************************************
25+ * *
26+ * Public Span_t Methods *
27+ * *
28+ ****************************************************************************/
29+
30+ bool span_t ::operator == (const span_t &o) const
31+ {
32+ if (start != o.start )
33+ return false ;
34+ if (last != o.last )
35+ return false ;
36+ if (span_id != o.span_id )
37+ return false ;
38+ if (planned != o.planned )
39+ return false ;
40+ if (in_system != o.in_system )
41+ return false ;
42+ if ((*(start_p) != *(o.start_p )))
43+ return false ;
44+ if ((*(last_p) != *(o.last_p )))
45+ return false ;
46+
47+ return true ;
48+ }
49+
50+ bool span_t ::operator != (const span_t &o) const
51+ {
52+ return !operator == (o);
53+ }
54+
2455/* ***************************************************************************
2556 * *
2657 * Public Planner Methods *
@@ -118,7 +149,7 @@ bool planner::operator== (const planner &o) const
118149 return false ;
119150 // m_p0 or o.m_p0 could be uninitialized
120151 if (m_p0 && o.m_p0 ) {
121- if (! scheduled_points_equal ( *m_p0, *(o.m_p0 ) ))
152+ if (*m_p0 != *(o.m_p0 ))
122153 return false ;
123154 } else if (m_p0 || o.m_p0 ) {
124155 return false ;
@@ -132,6 +163,11 @@ bool planner::operator== (const planner &o) const
132163 return true ;
133164}
134165
166+ bool planner::operator != (const planner &o) const
167+ {
168+ return !operator == (o);
169+ }
170+
135171planner::~planner ()
136172{
137173 // Destructor is nothrow
@@ -193,6 +229,30 @@ int planner::restore_track_points ()
193229 return rc;
194230}
195231
232+ int planner::update_total (uint64_t resource_total)
233+ {
234+ int64_t delta = resource_total - m_total_resources;
235+ int64_t tmp = 0 ;
236+ scheduled_point_t *point = nullptr ;
237+ if (delta == 0 )
238+ return 0 ;
239+ m_total_resources = static_cast <int64_t > (resource_total);
240+ point = m_sched_point_tree.get_state (m_plan_start);
241+ while (point) {
242+ // Prevent remaining from taking negative values. This should
243+ // reduce likelihood of errors when adding and removing spans.
244+ // If the performance penalty is non-negligible we can
245+ // investigate letting remaining take negative values.
246+ tmp = point->remaining + delta;
247+ if (tmp >= 0 )
248+ point->remaining = tmp;
249+ else
250+ point->remaining = 0 ;
251+ point = m_sched_point_tree.next (point);
252+ }
253+ return 0 ;
254+ }
255+
196256int64_t planner::get_total_resources () const
197257{
198258 return m_total_resources;
@@ -428,25 +488,6 @@ int planner::copy_maps (const planner &o)
428488 return rc;
429489}
430490
431- bool planner::scheduled_points_equal (const scheduled_point_t &lhs,
432- const scheduled_point_t &rhs) const
433- {
434- if (lhs.at != rhs.at )
435- return false ;
436- if (lhs.in_mt_resource_tree != rhs.in_mt_resource_tree )
437- return false ;
438- if (lhs.new_point != rhs.new_point )
439- return false ;
440- if (lhs.ref_count != rhs.ref_count )
441- return false ;
442- if (lhs.remaining != rhs.remaining )
443- return false ;
444- if (lhs.scheduled != rhs.scheduled )
445- return false ;
446-
447- return true ;
448- }
449-
450491bool planner::span_lookups_equal (const planner &o) const
451492{
452493 if (m_span_lookup.size () != o.m_span_lookup .size ())
@@ -460,23 +501,8 @@ bool planner::span_lookups_equal (const planner &o) const
460501 return false ;
461502 if (this_it.first != other->first )
462503 return false ;
463- if (this_it.second ->start != other->second ->start )
464- return false ;
465- if (this_it.second ->last != other->second ->last )
466- return false ;
467- if (this_it.second ->span_id != other->second ->span_id )
468- return false ;
469- if (this_it.second ->planned != other->second ->planned )
470- return false ;
471- if (this_it.second ->in_system != other->second ->in_system )
472- return false ;
473- if (this_it.second ->in_system != other->second ->in_system )
474- return false ;
475- if (!scheduled_points_equal (*(this_it.second ->start_p ),
476- *(other->second ->start_p )))
477- return false ;
478- if (!scheduled_points_equal (*(this_it.second ->last_p ),
479- *(other->second ->last_p )))
504+ // Compare span_t
505+ if (*(this_it.second ) != *(other->second ))
480506 return false ;
481507 }
482508 }
@@ -497,8 +523,7 @@ bool planner::avail_time_iters_equal (const planner &o) const
497523 if (this_it.first != other->first )
498524 return false ;
499525 if (this_it.second && other->second ) {
500- if (!scheduled_points_equal (*(this_it.second ),
501- *(other->second )))
526+ if (*(this_it.second ) != *(other->second ))
502527 return false ;
503528 } else if (this_it.second || other->second ) {
504529 return false ;
@@ -518,7 +543,7 @@ bool planner::trees_equal (const planner &o) const
518543 scheduled_point_t *o_pt =
519544 o.m_sched_point_tree .get_state (o.m_plan_start );
520545 while (this_pt) {
521- if (! scheduled_points_equal ( *this_pt, *o_pt) )
546+ if (*this_pt != *o_pt)
522547 return false ;
523548 this_pt = m_sched_point_tree.next (this_pt);
524549 o_pt = o.m_sched_point_tree .next (o_pt);
0 commit comments