We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
你提出的新想法中: type API struct { clients map[uint][]*client //我个人感觉这个还可以优化一些 lock sync.RWMutex pingPeriod time.Duration pongTimeout time.Duration upgrader *websocket.Upgrader } //个人想法 type API struct { clients map[uint]*userInfo lock sync.RWMutex pingPeriod time.Duration pongTimeout time.Duration upgrader *websocket.Upgrader }
type userInfo struct { userId uint clientLock sync.RWMutex allClients []*client //还可以保留一些其它信息 }
//这样的好处是 外层的锁只会做很少的事 //内层加锁是不影响到其他用户的,而且slice是有datarace问题的,不加锁会有问题
The text was updated successfully, but these errors were encountered:
No branches or pull requests
你提出的新想法中:
type API struct {
clients map[uint][]*client //我个人感觉这个还可以优化一些
lock sync.RWMutex
pingPeriod time.Duration
pongTimeout time.Duration
upgrader *websocket.Upgrader
}
//个人想法
type API struct {
clients map[uint]*userInfo
lock sync.RWMutex
pingPeriod time.Duration
pongTimeout time.Duration
upgrader *websocket.Upgrader
}
type userInfo struct {
userId uint
clientLock sync.RWMutex
allClients []*client
//还可以保留一些其它信息
}
//这样的好处是 外层的锁只会做很少的事
//内层加锁是不影响到其他用户的,而且slice是有datarace问题的,不加锁会有问题
The text was updated successfully, but these errors were encountered: