File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,8 @@ type ConnPool struct {
91
91
poolSize int
92
92
idleConnsLen int
93
93
94
- stats Stats
94
+ stats Stats
95
+ waitDurationNs atomic.Int64
95
96
96
97
_closed uint32 // atomic
97
98
}
@@ -318,7 +319,7 @@ func (p *ConnPool) waitTurn(ctx context.Context) error {
318
319
timers .Put (timer )
319
320
return ctx .Err ()
320
321
case p .queue <- struct {}{}:
321
- atomic . AddInt64 ( & p . stats . WaitDurationNs , time .Since (start ).Nanoseconds ())
322
+ p . waitDurationNs . Add ( time .Since (start ).Nanoseconds ())
322
323
atomic .AddUint32 (& p .stats .WaitCount , 1 )
323
324
if ! timer .Stop () {
324
325
<- timer .C
@@ -450,7 +451,7 @@ func (p *ConnPool) Stats() *Stats {
450
451
Misses : atomic .LoadUint32 (& p .stats .Misses ),
451
452
Timeouts : atomic .LoadUint32 (& p .stats .Timeouts ),
452
453
WaitCount : atomic .LoadUint32 (& p .stats .WaitCount ),
453
- WaitDurationNs : atomic . LoadInt64 ( & p . stats . WaitDurationNs ),
454
+ WaitDurationNs : p . waitDurationNs . Load ( ),
454
455
455
456
TotalConns : uint32 (p .Len ()),
456
457
IdleConns : uint32 (p .IdleLen ()),
You can’t perform that action at this time.
0 commit comments