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

[REQ] Explain destructor behavior for thread_pool #143

Closed
MakotoE opened this issue Mar 1, 2024 · 4 comments
Closed

[REQ] Explain destructor behavior for thread_pool #143

MakotoE opened this issue Mar 1, 2024 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@MakotoE
Copy link

MakotoE commented Mar 1, 2024

Describe the new feature
In the README.md, explain what would happen when the destructor of thread_pool is called.

Code example
N/A

Additional information

I see that ~thread_pool() will wait for all tasks to finish, then destroys all threads. It might be nice to state this in README.md, in the library reference section. I didn't find any mention of this. I think it is important to know.

@MakotoE MakotoE added the enhancement New feature or request label Mar 1, 2024
@bshoshany
Copy link
Owner

Hi @MakotoE and thanks for opening this issue! The reason that the destructor is not mentioned in README.md is that the user is not supposed to call the destructor manually, so it is not part of the public API, but an internal implementation detail. Is there any specific reason that the destructor should be mentioned in README.md?

@MakotoE
Copy link
Author

MakotoE commented Mar 1, 2024

Ok, the part about the visibility of the destructor makes sense. In my case, I was wondering if my app would close without delay, as tasks may be queued up in the thread pool. After seeing that the thread pool destructor may block to wait for the tasks, I decided that I should first purge the pool before destroying the pool.

The destructor may be hidden in the sense that a user should not call ~thread_pool() directly, but I feel like people will be worried about the destructor behavior for a thread pool when it loses scope. Maybe it's just me, I don't know. I'll just leave my opinion here, and we can see if other people think the same or not. No other issue in the past has talked about it.

@bshoshany
Copy link
Owner

Thanks for the suggestion! I will include a description of the destructor behavior of the thread pool in the documentation for the next release.

@bshoshany
Copy link
Owner

Update: This is now implemented in v4.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants