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

finish hw05 #37

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

finish hw05 #37

wants to merge 1 commit into from

Conversation

QifanWang
Copy link

  • login, register 等函数变成多线程安全的: 在函数内根据不同数据结构进行加锁。
  • login 的登录计时器改成基于 chrono 的:更改成 chrono 的 timepoint 记录登录时间。
  • 能利用 shared_mutex 区分读和写:为 usershas_login 分配两个 shared_mutex
  • lock_guard 系列符合 RAII 思想:为读/写操作使用 block + shared_lock/unique_lock 加解锁。
  • 让 ThreadPool::create 创建的线程保持后台运行不要退出:用 emplace_back 构造线程。
  • 等待 tpool 中所有线程都结束后再退出:tpool的析构函数里等待所有线程 join 完成。测试的线程数常数过大,需要定量等待所有线程并 clear()

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