From 61c281b71e8d388364432b0daa93148a1b54a322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ximo=20Cuadros?= Date: Tue, 31 Jan 2023 12:46:12 +0100 Subject: [PATCH] fix Submit(), on ARM 32-bit cpus --- pond.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pond.go b/pond.go index 9f16728..e5e6192 100644 --- a/pond.go +++ b/pond.go @@ -71,6 +71,14 @@ func Context(parentCtx context.Context) Option { // WorkerPool models a pool of workers type WorkerPool struct { + // Atomic counters, should be placed first so alignment is guaranteed + // for atomic operations. + workerCount int32 + idleWorkerCount int32 + waitingTaskCount uint64 + submittedTaskCount uint64 + successfulTaskCount uint64 + failedTaskCount uint64 // Configurable settings maxWorkers int maxCapacity int @@ -80,13 +88,6 @@ type WorkerPool struct { panicHandler func(interface{}) context context.Context contextCancel context.CancelFunc - // Atomic counters - workerCount int32 - idleWorkerCount int32 - waitingTaskCount uint64 - submittedTaskCount uint64 - successfulTaskCount uint64 - failedTaskCount uint64 // Private properties tasks chan func() tasksCloseOnce sync.Once