summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-01-25 22:53:35 +0300
committerValery Piashchynski <[email protected]>2021-01-25 22:53:35 +0300
commit7756eb25453c8006fbd75aa5c97159e96331b840 (patch)
tree9d385617e1eac1a4137054fbee540e397eb93a5f
parent43071e43a0743ff8c7913bba7819952962124355 (diff)
Fix map LoadAndDelete method for a sync.Map in go1.14
-rw-r--r--plugins/temporal/workflow/canceller.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/plugins/temporal/workflow/canceller.go b/plugins/temporal/workflow/canceller.go
index c38f447f..962c527f 100644
--- a/plugins/temporal/workflow/canceller.go
+++ b/plugins/temporal/workflow/canceller.go
@@ -4,13 +4,11 @@ import (
"sync"
)
-type (
- cancellable func() error
+type cancellable func() error
- canceller struct {
- ids sync.Map
- }
-)
+type canceller struct {
+ ids sync.Map
+}
func (c *canceller) register(id uint64, cancel cancellable) {
c.ids.Store(id, cancel)
@@ -23,11 +21,16 @@ func (c *canceller) discard(id uint64) {
func (c *canceller) cancel(ids ...uint64) error {
var err error
for _, id := range ids {
- cancel, ok := c.ids.LoadAndDelete(id)
+ cancel, ok := c.ids.Load(id)
if ok == false {
continue
}
+ // TODO return when minimum supported version will be go 1.15
+ // go1.14 don't have LoadAndDelete method
+ // It was introduced only in go1.15
+ c.ids.Delete(id)
+
err = cancel.(cancellable)()
if err != nil {
return err