Skip to content

Commit

Permalink
fix: correctly handle pause
Browse files Browse the repository at this point in the history
  • Loading branch information
Velka-DEV committed May 29, 2024
1 parent 2044a09 commit 3e72501
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/core/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func (c *Checker) internalCheckProcess(args *CheckProcessArgs) *CheckResult {
// Start starts the checker
func (c *Checker) Start() {
pool, err := ants.NewPoolWithFunc(c.Config.Threads, func(args interface{}) {
for c.Infos.State == CheckerStatePaused {
time.Sleep(100 * time.Millisecond)
}

checkArgs := args.(*CheckProcessArgs)
c.internalCheckProcess(checkArgs)
c.waitGroup.Done()
Expand Down Expand Up @@ -182,13 +186,11 @@ func (c *Checker) IsRunning() bool {
// It will not stop the current checks, but will prevent new ones from starting
func (c *Checker) Pause() {
c.Infos.State = CheckerStatePaused
c.workerPool.Tune(0)
}

// Resume resumes the checker
func (c *Checker) Resume() {
c.Infos.State = CheckerStateRunning
c.workerPool.Tune(c.Config.Threads)
}

// SetThreads sets the number of threads, and adjusts the worker pool accordingly
Expand Down

0 comments on commit 3e72501

Please sign in to comment.