@@ -17,12 +17,12 @@ var (
17
17
18
18
// PoolStats contains pool state information and accumulated stats.
19
19
type PoolStats struct {
20
- Requests uint64 // number of times a connection was requested by the pool
21
- Waits uint64 // number of times our pool had to wait for a connection
22
- Timeouts uint64 // number of times a wait timeout occurred
20
+ Requests uint32 // number of times a connection was requested by the pool
21
+ Waits uint32 // number of times our pool had to wait for a connection
22
+ Timeouts uint32 // number of times a wait timeout occurred
23
23
24
- TotalConns uint64 // the number of total connections in the pool
25
- FreeConns uint64 // the number of free connections in the pool
24
+ TotalConns uint32 // the number of total connections in the pool
25
+ FreeConns uint32 // the number of free connections in the pool
26
26
}
27
27
28
28
type pool interface {
@@ -237,7 +237,7 @@ func (p *connPool) Get() (cn *conn, isNew bool, err error) {
237
237
return
238
238
}
239
239
240
- atomic .AddUint64 (& p .stats .Requests , 1 )
240
+ atomic .AddUint32 (& p .stats .Requests , 1 )
241
241
242
242
// Fetch first non-idle connection, if available.
243
243
if cn = p .First (); cn != nil {
@@ -257,12 +257,12 @@ func (p *connPool) Get() (cn *conn, isNew bool, err error) {
257
257
}
258
258
259
259
// Otherwise, wait for the available connection.
260
- atomic .AddUint64 (& p .stats .Waits , 1 )
260
+ atomic .AddUint32 (& p .stats .Waits , 1 )
261
261
if cn = p .wait (); cn != nil {
262
262
return
263
263
}
264
264
265
- atomic .AddUint64 (& p .stats .Timeouts , 1 )
265
+ atomic .AddUint32 (& p .stats .Timeouts , 1 )
266
266
err = errPoolTimeout
267
267
return
268
268
}
@@ -315,11 +315,11 @@ func (p *connPool) FreeLen() int {
315
315
316
316
func (p * connPool ) Stats () * PoolStats {
317
317
stats := p .stats
318
- stats .Requests = atomic .LoadUint64 (& p .stats .Requests )
319
- stats .Waits = atomic .LoadUint64 (& p .stats .Waits )
320
- stats .Timeouts = atomic .LoadUint64 (& p .stats .Timeouts )
321
- stats .TotalConns = uint64 (p .Len ())
322
- stats .FreeConns = uint64 (p .FreeLen ())
318
+ stats .Requests = atomic .LoadUint32 (& p .stats .Requests )
319
+ stats .Waits = atomic .LoadUint32 (& p .stats .Waits )
320
+ stats .Timeouts = atomic .LoadUint32 (& p .stats .Timeouts )
321
+ stats .TotalConns = uint32 (p .Len ())
322
+ stats .FreeConns = uint32 (p .FreeLen ())
323
323
return & stats
324
324
}
325
325
0 commit comments