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

A few minor upgrades update of ThreadPool.h #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NITEACE
Copy link

@NITEACE NITEACE commented Jul 20, 2024

1.使用std::invoke_result替代std::result_of
std::result_of已被C++17中的std::invoke_result取代,前者在C++20中被弃用。为了保证代码的现代性和兼容性,使用了std::invoke_result。
2.捕获和处理任务中的异常
当前实现中,如果任务抛出异常,可能导致线程终止。所以我尝试在任务执行时捕获异常,并提供相应的处理机制。
3.增加线程池状态查询功能
增加了一些方法,可以查询线程池的状态,例如:当前活跃线程数、任务队列长度等,便于调试和监控。

1.使用std::invoke_result替代std::result_of
std::result_of已被C++17中的std::invoke_result取代,前者在C++20中被弃用。为了保证代码的现代性和兼容性,使用了std::invoke_result。
2.捕获和处理任务中的异常
当前实现中,如果任务抛出异常,可能导致线程终止。所以我尝试在任务执行时捕获异常,并提供相应的处理机制。
3.增加线程池状态查询功能
增加了一些方法,可以查询线程池的状态,例如:当前活跃线程数、任务队列长度等,便于调试和监控。
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