Skip to content

Commit

Permalink
explicit empty type
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed May 25, 2024
1 parent e01f0da commit bb5e771
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions web/download/multi.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ type Downloader struct {
Retries int
}

type empty struct{}

func (g *Downloader) Download(baseDir string) {
semaphore := make(chan struct{}, g.Threads) // Create a semaphore to limit concurrency
semaphore := make(chan empty, g.Threads) // Create a semaphore to limit concurrency
var wg sync.WaitGroup

for i := range g.Downloads {
wg.Add(1)
dl := g.Downloads[i]

semaphore <- struct{}{} // Acquire a slot in the semaphore
semaphore <- empty{} // Acquire a slot in the semaphore
go func() {
defer func() {
<-semaphore // Release the slot in the semaphore
Expand Down

0 comments on commit bb5e771

Please sign in to comment.