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

Use async instead of defered for threadpool threads. #8901

Closed
wants to merge 1 commit into from

Conversation

panyx0718
Copy link
Contributor

I don't have much background. Feel free to let me know "deferred" is the expected
behavior.

Reason for the change:
defered means you need to call get/wait first, then
the thread starts to run.
async means the thread starts ASAP, wait/get are only
used to get the result.

The code comment says:
To wait for the completion of the task, call std::future::wait()

Hence, user would expect wait() is not a method to start the thread.
It seems more reasonable to start running when the thread is available
instead of waiting for a wait/get call.

Reason:
defered means you need to call get/wait first, then
the thread starts to run.
async means the thread starts ASAP, wait/get are only
used to get the result.

The code comment says:
To wait for the completion of the task, call std::future::wait()

Hence, user would expect wait() is not a method to star the thread.
It seems more reasonable to start running when the thread is available.
@panyx0718 panyx0718 requested a review from reyoung March 9, 2018 04:57
@panyx0718
Copy link
Contributor Author

I printed out the starting sequence of deferred and async:
In deferred:
waiting
running
running
running
running done
running done
waiting done
waiting
waiting done
waiting
running done
waiting done
waiting all done

In async:
running
running
running
waiting
running done
running done
running done
waiting done
waiting
waiting done
waiting
waiting done
waiting all done

@paddle-bot-old paddle-bot-old bot closed this May 22, 2020
@paddle-bot-old
Copy link

Since you haven't replied for a long time, we have closed this issue/pr.
If the problem is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up.
由于您长期未回复,我们将关闭这个issue/pr。
若问题未解决或有后续问题,请随时重新打开,我们会继续跟进。

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

Successfully merging this pull request may close these issues.

1 participant