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

CheckInService的CheckIn方法 #80

Open
AlertBoy opened this issue Sep 16, 2020 · 1 comment
Open

CheckInService的CheckIn方法 #80

AlertBoy opened this issue Sep 16, 2020 · 1 comment

Comments

@AlertBoy
Copy link

CheckIn 方法这样加锁,不是同时只有一个人可以签到了么,用户一多 同时签到的时候不是要排队签到影响并发了么

func (s *checkInService) CheckIn(userId int64) error {
	s.m.Lock()
	defer s.m.Unlock()
	....
}
@bbbbbbbbbbbbba
Copy link
Collaborator

bbbbbbbbbbbbba commented Sep 23, 2020

CheckIn 方法这样加锁,不是同时只有一个人可以签到了么,用户一多 同时签到的时候不是要排队签到影响并发了么

func (s *checkInService) CheckIn(userId int64) error {
	s.m.Lock()
	defer s.m.Unlock()
	....
}

是的, 你说的对,我知道这个问题存在,我当时写的时候没考虑这个问题,这个地方是可以优化的。

你代码看的很仔细

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

No branches or pull requests

2 participants