summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/messageID.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-04-25 23:50:10 +0200
committerGitHub <noreply@github.com>2022-04-25 23:50:10 +0200
commit67adad3e08fe17d5f7e87468ea47aa76e1662255 (patch)
tree91314fac90d39254e66ae794decfcd21c10a7b20 /vendor/github.com/slack-go/slack/messageID.go
parent2fca3c756373577eab4e0120ccce62eecc1f5ad8 (diff)
downloadmatterbridge-msglm-67adad3e08fe17d5f7e87468ea47aa76e1662255.tar.gz
matterbridge-msglm-67adad3e08fe17d5f7e87468ea47aa76e1662255.tar.bz2
matterbridge-msglm-67adad3e08fe17d5f7e87468ea47aa76e1662255.zip
Update dependencies (#1813)
Diffstat (limited to 'vendor/github.com/slack-go/slack/messageID.go')
-rw-r--r--vendor/github.com/slack-go/slack/messageID.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/vendor/github.com/slack-go/slack/messageID.go b/vendor/github.com/slack-go/slack/messageID.go
index a17472b4..689ee80d 100644
--- a/vendor/github.com/slack-go/slack/messageID.go
+++ b/vendor/github.com/slack-go/slack/messageID.go
@@ -1,6 +1,6 @@
package slack
-import "sync"
+import "sync/atomic"
// IDGenerator provides an interface for generating integer ID values.
type IDGenerator interface {
@@ -11,20 +11,20 @@ type IDGenerator interface {
// concurrent use by multiple goroutines.
func NewSafeID(startID int) IDGenerator {
return &safeID{
- nextID: startID,
- mutex: &sync.Mutex{},
+ nextID: int64(startID),
}
}
type safeID struct {
- nextID int
- mutex *sync.Mutex
+ nextID int64
}
+// make sure safeID implements the IDGenerator interface.
+var _ IDGenerator = (*safeID)(nil)
+
+// Next implements IDGenerator.Next.
func (s *safeID) Next() int {
- s.mutex.Lock()
- defer s.mutex.Unlock()
- id := s.nextID
- s.nextID++
- return id
+ id := atomic.AddInt64(&s.nextID, 1)
+
+ return int(id)
}