1
0
mirror of https://github.com/redis/go-redis.git synced 2025-08-01 16:06:54 +03:00

internal/pool: replace atomic.Value with int64

This commit is contained in:
Vladimir Mihailenco
2019-05-31 17:54:30 +03:00
parent 7a91ed0df5
commit 6c72dc807e
7 changed files with 28 additions and 35 deletions

View File

@ -13,14 +13,13 @@ var noDeadline = time.Time{}
type Conn struct {
netConn net.Conn
rd *proto.Reader
rdLocked bool
wr *proto.Writer
rd *proto.Reader
wr *proto.Writer
Inited bool
pooled bool
createdAt time.Time
usedAt atomic.Value
usedAt int64 // atomic
}
func NewConn(netConn net.Conn) *Conn {
@ -35,11 +34,12 @@ func NewConn(netConn net.Conn) *Conn {
}
func (cn *Conn) UsedAt() time.Time {
return cn.usedAt.Load().(time.Time)
unix := atomic.LoadInt64(&cn.usedAt)
return time.Unix(unix, 0)
}
func (cn *Conn) SetUsedAt(tm time.Time) {
cn.usedAt.Store(tm)
atomic.StoreInt64(&cn.usedAt, tm.Unix())
}
func (cn *Conn) SetNetConn(netConn net.Conn) {