Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
难点主要在如何写线程池,因为不太会用MTQueue,所以从stack overflow上找了一个改了改,核心思想就是先建和cpu核心数相同数量的线程,然后生产者消费者模型,真实线程while(true)循环作为消费者,产生的线程作为生产者往面送。done函数是用来手动停止线程池工作。
然后就是有读有写的段落用shared_mutex读写锁,只读或者只写的段落用普通锁就可以了。
为了体现RAII思想在thread pool的析构函数里把所有线程join一边即可。