9 // SimpleTask is in an implementation of tasklog.Task which prints out messages
11 type SimpleTask struct {
12 // ch is used to transmit task updates.
15 // wg is used to wait between closing the channel, and acknowledging
16 // that the close-related operations have been completed by the
21 // NewSimpleTask returns a new *SimpleTask instance.
22 func NewSimpleTask() *SimpleTask {
24 ch: make(chan *Update),
25 wg: new(sync.WaitGroup),
29 // Log logs a string with no formatting verbs.
30 func (s *SimpleTask) Log(str string) {
34 // Logf logs some formatted string, which is interpreted according to the rules
35 // defined in package "fmt".
36 func (s *SimpleTask) Logf(str string, vals ...interface{}) {
38 S: fmt.Sprintf(str, vals...),
43 // Complete notes that the task is completed by closing the Updates channel and
44 // yields the logger to the next Task. Complete blocks until the *tasklog.Logger
45 // has acknowledged completion of this task.
46 func (s *SimpleTask) Complete() {
52 // OnComplete implements an interface which receives a call to this method when
53 // the *tasklog.Logger has finished processing this task, but before it has
54 // accepted new tasks.
55 func (s *SimpleTask) OnComplete() {
59 // Updates implements Task.Updates and returns a channel of updates which is
60 // closed when Complete() is called.
61 func (s *SimpleTask) Updates() <-chan *Update {
65 // Throttled implements Task.Throttled and returns false, indicating that this
66 // task is not throttled.
67 func (s *SimpleTask) Throttled() bool { return false }