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

示例中的Manager同时只支持32个session吗 #50

Closed
zrj12345 opened this issue Sep 14, 2016 · 1 comment
Closed

示例中的Manager同时只支持32个session吗 #50

zrj12345 opened this issue Sep 14, 2016 · 1 comment

Comments

@zrj12345
Copy link

`func (manager *Manager) putSession(session *Session) {
smap := &manager.sessionMaps[session.id%sessionMapNum]
smap.Lock()
defer smap.Unlock()

smap.sessions[session.id] = session
manager.disposeWait.Add(1)

}`

`const sessionMapNum = 32

type Manager struct {
sessionMaps [sessionMapNum]sessionMap
disposeFlag bool
disposeOnce sync.Once
disposeWait sync.WaitGroup
}`

按照README说的 session的字面含义是会话,就是一次对话过程。每一个连接的生命周期被表达为一个会话过程,这个过程中通讯双方的消息有来有往。
意思是说同时只能有32个连接在线?

@bg5sbk
Copy link
Contributor

bg5sbk commented Sep 14, 2016

32个sessionMap是为了降低存取session时的锁颗粒度,每个sessionMap里可以存放任意多的Session

@bg5sbk bg5sbk closed this as completed Sep 22, 2016
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