dimanche 16 février 2020

What's the most idiomatic way to call function from "sub"-struct to "parent"-struct?

I have two structs

type task struct {}
type tasks struct []{
     t task 
}

I want to run one task and after it finished to notify the next task on tasks. Assume tasks would have to process such data to trigger next task. For example, after task1 and task2finished, then run task3.

So this one task.finished() have to call the func on tasks.runNextTask().

What's the most idiomatic way to call function from "sub"-struct to "parent"-struct?

Should I introduce a new struct that stores the information needed for exchange called "taskManager"?

Aucun commentaire:

Enregistrer un commentaire