(newThreads int)
| 40 | } |
| 41 | |
| 42 | func (this *Limiter) SetThreads(newThreads int) { |
| 43 | if newThreads <= 0 { |
| 44 | newThreads = this.countDefault |
| 45 | } |
| 46 | |
| 47 | if newThreads != this.count { |
| 48 | var threadsChan = make(chan struct{}, newThreads) |
| 49 | for i := 0; i < newThreads; i++ { |
| 50 | threadsChan <- struct{}{} |
| 51 | } |
| 52 | |
| 53 | this.threads = threadsChan |
| 54 | this.count = newThreads |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func (this *Limiter) Ack() { |
| 59 | <-this.threads |
no outgoing calls