Skip to content

Commit

Permalink
Fix go panic caused by unaligned atomic fields on certain architectures.
Browse files Browse the repository at this point in the history
Signed-off-by: Danny Wensley <danny@wensley.eu>
  • Loading branch information
techninja1008 committed Mar 16, 2019
1 parent 4d89945 commit e32cc4d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions go/pools/resource_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,20 @@ type Resource interface {

// ResourcePool allows you to use a pool of resources.
type ResourcePool struct {
resources chan resourceWrapper
factory Factory
capacity sync2.AtomicInt64
idleTimeout sync2.AtomicDuration
idleTimer *timer.Timer

// stats
// stats. Atomic fields must remain at the top in order to prevent panics on certain architectures.
available sync2.AtomicInt64
active sync2.AtomicInt64
inUse sync2.AtomicInt64
waitCount sync2.AtomicInt64
waitTime sync2.AtomicDuration
idleClosed sync2.AtomicInt64

capacity sync2.AtomicInt64
idleTimeout sync2.AtomicDuration

resources chan resourceWrapper
factory Factory
idleTimer *timer.Timer
}

type resourceWrapper struct {
Expand Down

0 comments on commit e32cc4d

Please sign in to comment.