tasks: show resources

This commit is contained in:
André Roth
2026-06-09 10:09:41 +02:00
parent 5f5104389a
commit d5b1482ab5
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -67,7 +67,7 @@ func (list *List) consumer() {
task.processReturnValue = retValue task.processReturnValue = retValue
} }
list.usedResources.Free(task.resources) list.usedResources.Free(task.Resources)
task.wgTask.Done() task.wgTask.Done()
list.wg.Done() list.wg.Done()
@@ -76,9 +76,9 @@ func (list *List) consumer() {
for _, t := range list.tasks { for _, t := range list.tasks {
if t.State == IDLE { if t.State == IDLE {
// check resources // check resources
blockingTasks := list.usedResources.UsedBy(t.resources) blockingTasks := list.usedResources.UsedBy(t.Resources)
if len(blockingTasks) == 0 { if len(blockingTasks) == 0 {
list.usedResources.MarkInUse(t.resources, t) list.usedResources.MarkInUse(t.Resources, t)
// unlock list since queueing may block // unlock list since queueing may block
list.Unlock() list.Unlock()
unlocked = true unlocked = true
@@ -219,7 +219,7 @@ func (list *List) RunTaskInBackground(name string, resources []string, process P
// if not, task will be queued by the consumer once resources are available // if not, task will be queued by the consumer once resources are available
tasks := list.usedResources.UsedBy(resources) tasks := list.usedResources.UsedBy(resources)
if len(tasks) == 0 { if len(tasks) == 0 {
list.usedResources.MarkInUse(task.resources, task) list.usedResources.MarkInUse(task.Resources, task)
// queueing task might block if channel not ready, unlock list before queueing // queueing task might block if channel not ready, unlock list before queueing
list.Unlock() list.Unlock()
list.queue <- task list.queue <- task
+2 -2
View File
@@ -52,7 +52,7 @@ type Task struct {
Name string Name string
ID int ID int
State State State State
resources []string Resources []string
wgTask *sync.WaitGroup wgTask *sync.WaitGroup
} }
@@ -65,7 +65,7 @@ func NewTask(process Process, name string, ID int, resources []string, wgTask *s
Name: name, Name: name,
ID: ID, ID: ID,
State: IDLE, State: IDLE,
resources: resources, Resources: resources,
wgTask: wgTask, wgTask: wgTask,
} }
return task return task