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

hw05 #18

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

hw05 #18

wants to merge 3 commits into from

Conversation

adelacvg
Copy link

难点主要在如何写线程池,因为不太会用MTQueue,所以从stack overflow上找了一个改了改,核心思想就是先建和cpu核心数相同数量的线程,然后生产者消费者模型,真实线程while(true)循环作为消费者,产生的线程作为生产者往面送。done函数是用来手动停止线程池工作。

然后就是有读有写的段落用shared_mutex读写锁,只读或者只写的段落用普通锁就可以了。

为了体现RAII思想在thread pool的析构函数里把所有线程join一边即可。

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