Skip to content

Commit

Permalink
change SessionPool's List as List ref
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxins committed Aug 29, 2024
1 parent 6515309 commit 890329f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions session_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import (
//
// Notice that all queries will be executed in the default space specified in the pool config.
type SessionPool struct {
idleSessions list.List
activeSessions list.List
idleSessions *list.List
activeSessions *list.List
conf SessionPoolConf
tz timezoneInfo
log Logger
Expand Down Expand Up @@ -654,7 +654,7 @@ func parseParams(params map[string]interface{}) (map[string]*nebula.Value, error
func (pool *SessionPool) removeSessionFromActive(session *pureSession) {
pool.rwLock.Lock()
defer pool.rwLock.Unlock()
l := &pool.activeSessions
l := pool.activeSessions
for ele := l.Front(); ele != nil; ele = ele.Next() {
if ele.Value.(*pureSession) == session {
l.Remove(ele)
Expand All @@ -665,14 +665,14 @@ func (pool *SessionPool) removeSessionFromActive(session *pureSession) {
func (pool *SessionPool) addSessionToActive(session *pureSession) {
pool.rwLock.Lock()
defer pool.rwLock.Unlock()
l := &pool.activeSessions
l := pool.activeSessions
l.PushBack(session)
}

func (pool *SessionPool) removeSessionFromIdle(session *pureSession) {
pool.rwLock.Lock()
defer pool.rwLock.Unlock()
l := &pool.idleSessions
l := pool.idleSessions
for ele := l.Front(); ele != nil; ele = ele.Next() {
if ele.Value.(*pureSession) == session {
l.Remove(ele)
Expand All @@ -683,21 +683,21 @@ func (pool *SessionPool) removeSessionFromIdle(session *pureSession) {
func (pool *SessionPool) addSessionToIdle(session *pureSession) {
pool.rwLock.Lock()
defer pool.rwLock.Unlock()
l := &pool.idleSessions
l := pool.idleSessions
l.PushBack(session)
}

// returnSession returns a session from active list to the idle list.
func (pool *SessionPool) returnSession(session *pureSession) {
pool.rwLock.Lock()
defer pool.rwLock.Unlock()
l := &pool.activeSessions
l := pool.activeSessions
for ele := l.Front(); ele != nil; ele = ele.Next() {
if ele.Value.(*pureSession) == session {
l.Remove(ele)
}
}
l = &pool.idleSessions
l = pool.idleSessions
l.PushBack(session)
session.returnedAt = time.Now()
}
Expand Down

0 comments on commit 890329f

Please sign in to comment.