dd8eaef97d
- Reorganize code into cmd/bilidown and internal/ packages - Rename client/ to web/ for frontend source - Remove systray dependency for headless web service - Embed static files into binary using go:embed - Update import paths to use internal/ prefix - Update .gitignore with common patterns Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
29 lines
375 B
Go
29 lines
375 B
Go
package util
|
|
|
|
import "sync"
|
|
|
|
type Semaphore struct {
|
|
ch chan struct{}
|
|
wg sync.WaitGroup
|
|
}
|
|
|
|
func NewSemaphore(concurrency int) *Semaphore {
|
|
return &Semaphore{
|
|
ch: make(chan struct{}, concurrency),
|
|
}
|
|
}
|
|
|
|
func (s *Semaphore) Acquire() {
|
|
s.ch <- struct{}{}
|
|
s.wg.Add(1)
|
|
}
|
|
|
|
func (s *Semaphore) Release() {
|
|
<-s.ch
|
|
s.wg.Done()
|
|
}
|
|
|
|
func (s *Semaphore) Wait() {
|
|
s.wg.Wait()
|
|
}
|