MCPcopy Create free account
hub / github.com/arkhipenko/TaskScheduler / deleteTask

Method deleteTask

src/TaskScheduler.h:1130–1174  ·  view source on GitHub ↗

Deletes specific Task from the execution chain * @param &aTask - reference to the task to be deleted from the chain */

Source from the content-addressed store, hash-verified

1128 * @param &aTask - reference to the task to be deleted from the chain
1129 */
1130void Scheduler::deleteTask(Task& aTask) {
1131// Can only delete own tasks
1132 if (aTask.iScheduler != this)
1133 return;
1134
1135 iEnabled = false;
1136 iChainLength--;
1137
1138 // If execute() is mid-iteration and this task is next in line,
1139 // advance the pointer before we unlink and the memory is freed.
1140 if (iNextExecute == &aTask)
1141 iNextExecute = aTask.iNext;
1142
1143 aTask.iScheduler = NULL;
1144 if (aTask.iPrev == NULL) {
1145 if (aTask.iNext == NULL) {
1146 iFirst = NULL;
1147 iLast = NULL;
1148 iEnabled = true;
1149 return;
1150 }
1151 else {
1152 aTask.iNext->iPrev = NULL;
1153 iFirst = aTask.iNext;
1154 aTask.iNext = NULL;
1155 iEnabled = true;
1156 return;
1157 }
1158 }
1159
1160 if (aTask.iNext == NULL) {
1161 aTask.iPrev->iNext = NULL;
1162 iLast = aTask.iPrev;
1163 aTask.iPrev = NULL;
1164 iEnabled = true;
1165 return;
1166 }
1167
1168 aTask.iPrev->iNext = aTask.iNext;
1169 aTask.iNext->iPrev = aTask.iPrev;
1170 aTask.iPrev = NULL;
1171 aTask.iNext = NULL;
1172
1173 iEnabled = true;
1174}
1175
1176/** Disables all tasks in the execution chain
1177 * Convenient for error situations, when the only

Callers 3

~TaskMethod · 0.80
TEST_FFunction · 0.80
t1CallbackFunction · 0.80

Calls

no outgoing calls

Tested by 1

TEST_FFunction · 0.64