Limit number of simultaneous file extractions to prevent hardlock
Added helper extraction functions chmod & chown is now set after a folder's extraction to prevent permission issues
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user