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

Pause API is needed in some scenario #190

Open
lilien1010 opened this issue Oct 13, 2021 · 2 comments
Open

Pause API is needed in some scenario #190

lilien1010 opened this issue Oct 13, 2021 · 2 comments
Assignees
Labels
proposal Proposal for this repo waiting for response waiting for the response from commenter

Comments

@lilien1010
Copy link
Contributor

in our case, we need a pool.Pause() to pause all jobs, and use pool.Resume() to restart the jobs.

@lilien1010 lilien1010 added the proposal Proposal for this repo label Oct 13, 2021
@panjf2000
Copy link
Owner

panjf2000 commented Oct 19, 2021

What did you mean by pausing and resuming jobs? I don't think that ants should interfere with the internal logic, or you were talking about ants intercepting new tasks (by pool.Pause()) and undoing it (by pool.Resume())?

@panjf2000 panjf2000 added the waiting for response waiting for the response from commenter label Oct 19, 2021
@timo-klarshift
Copy link

You can simply implement Pause() and Resume() in some wrapping code. Just keep track of the state (running & paused) and if paused stop submitting new tasks to the pool (or stop reading tasks from a channel). And after resuming continue to submit tasks to the pool...
IMO this is userland logic and there is no need for this library to handle such things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Proposal for this repo waiting for response waiting for the response from commenter
Projects
None yet
Development

No branches or pull requests

3 participants