26 #include "../util/PlanningUtil.h"
37 auto currentTaskStatus = taskStatus.load();
39 bool invalidTransition =
false;
40 switch (newTaskStatus)
42 case TaskStatus::eNew:
43 case TaskStatus::eTaskStatusSize:
44 invalidTransition =
true;
47 case TaskStatus::eQueued:
48 if (currentTaskStatus != TaskStatus::eNew)
50 invalidTransition =
true;
53 case TaskStatus::ePlanning:
54 if (currentTaskStatus != TaskStatus::eQueued)
56 invalidTransition =
true;
59 case TaskStatus::eRefining:
60 if (currentTaskStatus != TaskStatus::ePlanning)
62 invalidTransition =
true;
65 case TaskStatus::ePlanningAborted:
67 (currentTaskStatus != TaskStatus::eNew) &&
68 (currentTaskStatus != TaskStatus::eQueued) &&
69 (currentTaskStatus != TaskStatus::ePlanning)
72 invalidTransition =
true;
75 case TaskStatus::ePlanningFailed:
76 if (currentTaskStatus != TaskStatus::ePlanning)
78 invalidTransition =
true;
81 case TaskStatus::eRefinementAborted:
82 if (currentTaskStatus != TaskStatus::eRefining)
84 invalidTransition =
true;
87 case TaskStatus::eDone:
89 (currentTaskStatus != TaskStatus::eRefining) &&
90 (currentTaskStatus != TaskStatus::ePlanning)
93 invalidTransition =
true;
96 case TaskStatus::eException:
99 invalidTransition =
true;
101 if (invalidTransition)
103 if (currentTaskStatus != newTaskStatus)
113 if (taskStatus.compare_exchange_strong(currentTaskStatus, newTaskStatus))
122 if (newTaskStatus == TaskStatus::eRefining)
127 for (
auto& cb : taskStatusCallbacks)