d2c72f9464
Added helper extraction functions chmod & chown is now set after a folder's extraction to prevent permission issues
24 lines
314 B
Go
24 lines
314 B
Go
package threadmanager
|
|
|
|
type Manager struct {
|
|
c chan int
|
|
}
|
|
|
|
func NewManager(maxRoutines int) *Manager {
|
|
m := &Manager{
|
|
c: make(chan int, maxRoutines),
|
|
}
|
|
for i := 0; i < maxRoutines; i++ {
|
|
m.c <- i
|
|
}
|
|
return m
|
|
}
|
|
|
|
func (m *Manager) Lock() int {
|
|
return <-m.c
|
|
}
|
|
|
|
func (m *Manager) Unlock(n int) {
|
|
m.c <- n
|
|
}
|