Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
1、时间的话用duration_cast可以两个时间点转换成秒,从而知道多上时间登录过;
2、do_register函数是写函数,所以用std::unique_lock;
3、do_login函数读取数据的时候为读函数用的是std::shared_lock;而在后面有用往里面写时间,用得是std::unique_lock;
4、do_queryuser函数写读函数,所以用std::shared_lock即可;
5、让thread后台不退出,则需要加上join()函数即可,也可以写在析构函数里,这样符合RAII思想,但是我没那样做;
另外,我想开始的时候就给threads,reserver一个值,提高速度,但是如代码所示,报错,不知为何;还有就是不知是不是rand()函数的问题,我这里测试满屏幕都是zhangxinxi没别的名字了,很怪。
对了,之所以换成英文字母是我的编译器编译中文的时候报错,不得不为之。