Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing a job that is not registered causes removal of the last registered job #64

Open
kbrezina opened this issue Jan 24, 2019 · 1 comment

Comments

@kbrezina
Copy link
Contributor

see

s.size = s.size - 1

@kbrezina
Copy link
Contributor Author

A safer implementation could be following:

// Remove specific job j
func (s *Scheduler) Remove(j interface{}) {
	i := 0
	found := false

	for ; i < s.size; i++ {
		if s.jobs[i].jobFunc == getFunctionName(j) {
			found = true
			break
		}
	}

	if !found {
		return
	}

	for j := (i + 1); j < s.size; j++ {
		s.jobs[i] = s.jobs[j]
		i++
	}
	s.size = s.size - 1
}

@kbrezina kbrezina changed the title Removing a job that is not registered causes a removal of the last registered job Removing a job that is not registered causes removal of the last registered job Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant