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.
login
,register
等函数变成多线程安全的: 在函数内根据不同数据结构进行加锁。login
的登录计时器改成基于 chrono 的:更改成 chrono 的 timepoint 记录登录时间。shared_mutex
区分读和写:为users
与has_login
分配两个shared_mutex
。lock_guard
系列符合 RAII 思想:为读/写操作使用 block + shared_lock/unique_lock 加解锁。emplace_back
构造线程。join
完成。测试的线程数常数过大,需要定量等待所有线程并clear()
。