github.com/git-lfs/git-lfs@v2.5.2+incompatible/tasklog/waiting_task.go (about) 1 package tasklog 2 3 import ( 4 "fmt" 5 "time" 6 ) 7 8 // WaitingTask represents a task for which the total number of items to do work 9 // is on is unknown. 10 type WaitingTask struct { 11 // ch is used to transmit task updates. 12 ch chan *Update 13 } 14 15 // NewWaitingTask returns a new *WaitingTask. 16 func NewWaitingTask(msg string) *WaitingTask { 17 ch := make(chan *Update, 1) 18 ch <- &Update{ 19 S: fmt.Sprintf("%s: ...", msg), 20 At: time.Now(), 21 } 22 23 return &WaitingTask{ch: ch} 24 } 25 26 // Complete marks the task as completed. 27 func (w *WaitingTask) Complete() { 28 close(w.ch) 29 } 30 31 // Done implements Task.Done and returns a channel which is closed when 32 // Complete() is called. 33 func (w *WaitingTask) Updates() <-chan *Update { 34 return w.ch 35 } 36 37 // Throttled implements Task.Throttled and returns true, indicating that this 38 // task is Throttled. 39 func (w *WaitingTask) Throttled() bool { return true }