Fix: it's not slow as shit anymore
This commit is contained in:
parent
25f4048e70
commit
9540518c84
|
@ -12,6 +12,9 @@ func (s *Swamp) Start() error {
|
|||
// tossUp feeds jobs to pond continuously
|
||||
go s.jobSpawner()
|
||||
s.started = true
|
||||
s.mu.Lock()
|
||||
s.Status = Running
|
||||
s.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
1
defs.go
1
defs.go
|
@ -165,6 +165,7 @@ func NewDefaultSwamp() *Swamp {
|
|||
|
||||
quit: make(chan bool),
|
||||
mu: &sync.RWMutex{},
|
||||
Status: Paused,
|
||||
}
|
||||
|
||||
s.swampmap = swampMap{
|
||||
|
|
|
@ -54,5 +54,10 @@ func (s *Swamp) GetRecyclingStatus() bool {
|
|||
return s.swampopt.recycle
|
||||
}
|
||||
|
||||
|
||||
// TODO: Implement ways to access worker pool (pond) statistics
|
||||
// GetWorkers retrieves pond worker statistics:
|
||||
// * return MaxWorkers, RunningWorkers, IdleWorkers
|
||||
func (s *Swamp) GetWorkers() (int, int, int) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
return s.pool.MaxWorkers(), s.pool.RunningWorkers(), s.pool.IdleWorkers()
|
||||
}
|
||||
|
|
|
@ -53,10 +53,12 @@ func (s *Swamp) SetValidationTimeout(newtimeout int) {
|
|||
|
||||
// SetMaxWorkers set the maximum workers for proxy checking, this must be set before calling LoadProxyTXT for the first time.
|
||||
func (s *Swamp) SetMaxWorkers(num int) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.Status == Running {
|
||||
return errors.New("can't change max workers during proxypool operation, try pausing first")
|
||||
}
|
||||
s.pool.Stop()
|
||||
s.pool.StopAndWait()
|
||||
s.swampopt.maxWorkers = num
|
||||
s.pool = pond.New(s.swampopt.maxWorkers, 1000000, pond.PanicHandler(func(p interface{}) {
|
||||
fmt.Println("WORKER PANIC! ", p)
|
||||
|
|
Loading…
Reference in New Issue