Merge pull request #14 from alitto/bug/fix-waiting-count
Prevent WaitingTasks counter to wrap around and upgrade to Go v1.16
This commit is contained in:
@@ -11,6 +11,7 @@ go:
|
|||||||
- 1.13.x
|
- 1.13.x
|
||||||
- 1.14.x
|
- 1.14.x
|
||||||
- 1.15.x
|
- 1.15.x
|
||||||
|
- 1.16.x
|
||||||
|
|
||||||
# Enable Go Modules
|
# Enable Go Modules
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
module github.com/alitto/pond/examples/dynamic_size
|
module github.com/alitto/pond/examples/dynamic_size
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alitto/pond v1.5.0
|
github.com/alitto/pond v1.5.1
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/alitto/pond => ../../
|
replace github.com/alitto/pond => ../../
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
module github.com/alitto/pond/examples/fixed_size
|
module github.com/alitto/pond/examples/fixed_size
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alitto/pond v1.5.0
|
github.com/alitto/pond v1.5.1
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/alitto/pond => ../../
|
replace github.com/alitto/pond => ../../
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
module github.com/alitto/pond/examples/fixed_size
|
module github.com/alitto/pond/examples/fixed_size
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alitto/pond v1.5.0
|
github.com/alitto/pond v1.5.1
|
||||||
github.com/prometheus/client_golang v1.9.0
|
github.com/prometheus/client_golang v1.9.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
module github.com/alitto/pond/examples/task_group
|
module github.com/alitto/pond/examples/task_group
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alitto/pond v1.5.0
|
github.com/alitto/pond v1.5.1
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/alitto/pond => ../../
|
replace github.com/alitto/pond => ../../
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module github.com/alitto/pond
|
module github.com/alitto/pond
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
|
|||||||
@@ -211,13 +211,15 @@ func (p *WorkerPool) submit(task func(), canWaitForIdleWorker bool) (submitted b
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
// Increment submitted and waiting task counters as soon as we receive a task
|
||||||
if submitted {
|
atomic.AddUint64(&p.submittedTaskCount, 1)
|
||||||
// Increment submitted task count
|
atomic.AddUint64(&p.waitingTaskCount, 1)
|
||||||
atomic.AddUint64(&p.submittedTaskCount, 1)
|
|
||||||
|
|
||||||
// Increment waiting task count
|
defer func() {
|
||||||
atomic.AddUint64(&p.waitingTaskCount, 1)
|
if !submitted {
|
||||||
|
// Task was not sumitted to the pool, decrement submitted and waiting task counters
|
||||||
|
atomic.AddUint64(&p.submittedTaskCount, ^uint64(0))
|
||||||
|
atomic.AddUint64(&p.waitingTaskCount, ^uint64(0))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user