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:
Caleb Gardner
2023-04-17 10:22:10 -05:00
parent 2ba4551fb9
commit d2c72f9464
5 changed files with 118 additions and 21 deletions
+23
View File
@@ -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
}