(concurrency int)
| 32 | } |
| 33 | |
| 34 | func NewBuildQueue(concurrency int) *BuildQueue { |
| 35 | if concurrency <= 0 { |
| 36 | concurrency = 1 // ensure at least 1 concurrent task |
| 37 | } |
| 38 | return &BuildQueue{ |
| 39 | queue: map[*BuildTask]struct{}{}, |
| 40 | pending: list.New(), |
| 41 | tasks: map[string]*BuildTask{}, |
| 42 | chann: concurrency, |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // Add adds a new build task to the queue. |
| 47 | func (q *BuildQueue) Add(ctx *BuildContext) chan BuildOutput { |