MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / completeTask

Method completeTask

internal/taskmanager/manager.go:208–234  ·  view source on GitHub ↗
(task *Task, status TaskStatus, err error)

Source from the content-addressed store, hash-verified

206}
207
208func (tm *TaskManager) completeTask(task *Task, status TaskStatus, err error) {
209 tm.mu.Lock()
210 task.Status = status
211 task.Error = err
212 task.FinishedAt = time.Now()
213
214 key := taskKey(task.TargetNode, task.TargetVMID)
215
216 // Remove from active
217 delete(tm.activeTasks, key)
218
219 // Check queue for next task, respecting max running task cap.
220 nextTask := tm.dequeueNextStartableLocked(key)
221 tm.mu.Unlock()
222
223 if task.OnComplete != nil {
224 go task.OnComplete(err)
225 }
226
227 if tm.updateNotify != nil {
228 go tm.updateNotify()
229 }
230
231 if nextTask != nil {
232 go tm.runTask(nextTask)
233 }
234}
235
236func (tm *TaskManager) dequeueNextStartableLocked(preferredKey string) *Task {
237 if len(tm.activeTasks) >= tm.maxRunning {

Callers 1

runTaskMethod · 0.95

Calls 3

runTaskMethod · 0.95
taskKeyFunction · 0.85

Tested by

no test coverage detected