probe/server/session.go
crusader a1ecf315c6 ing
2018-09-04 19:09:15 +09:00

37 lines
592 B
Go

package server
import (
"sync"
server "git.loafle.net/overflow/server-go"
)
type Session struct {
TargetID string
ServletCtx server.ServletCtx
}
var sessionPool sync.Pool
func RetainSession(targetID string, servletCtx server.ServletCtx) *Session {
v := sessionPool.Get()
var _session *Session
if v == nil {
_session = &Session{}
} else {
_session = v.(*Session)
}
_session.TargetID = targetID
_session.ServletCtx = servletCtx
return _session
}
func ReleaseSession(_session *Session) {
_session.TargetID = ""
_session.ServletCtx = nil
sessionPool.Put(_session)
}