Skip to content

How can a task function be notified of pool stop and abort? #45

Answered by alitto
romdr asked this question in Q&A
Discussion options

You must be logged in to vote

Hey!

A few things to note here:

  • If you attempt to submit a task to a pool that has already been stopped, then the call to the Submit() method will return a non-nill error.
  • If you stop the pool after the task was submitted, then there are 2 possibilities:
    • The task is still in the queue (it hasn't started yet) -> what happens here depends on the method used to stop the pool. If you call Stop() then it won't be executed. If you call StopAndWait() then it will be executed. More info here.
    • The task is being executed -> in this case, the task will continue to execute until it completes.

That said, if we focus on the last scenario (task is running while the pool is stopped) then you have a …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by romdr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants