Skip to content

Commit

Permalink
sync upstream
Browse files Browse the repository at this point in the history
ref:f822f0be6169f6f5f8d7990163a001723d62fd67
  • Loading branch information
arcadia-devtools committed Aug 5, 2020
1 parent 52e00fc commit 8ebba4e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions table/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"io"
"sync"
"time"

"github.com/yandex-cloud/ydb-go-sdk"
Expand Down Expand Up @@ -76,18 +77,23 @@ type Session struct {
qcache lru.Cache
qhash queryHasher

closed bool
onClose []func()
closeMux sync.Mutex
closed bool
onClose []func()
}

func (s *Session) OnClose(cb func()) {
s.closeMux.Lock()
defer s.closeMux.Unlock()
if s.closed {
return
}
s.onClose = append(s.onClose, cb)
}

func (s *Session) Close(ctx context.Context) (err error) {
s.closeMux.Lock()
defer s.closeMux.Unlock()
if s.closed {
return nil
}
Expand Down

0 comments on commit 8ebba4e

Please sign in to comment.