From 67adad3e08fe17d5f7e87468ea47aa76e1662255 Mon Sep 17 00:00:00 2001 From: Wim Date: Mon, 25 Apr 2022 23:50:10 +0200 Subject: Update dependencies (#1813) --- vendor/github.com/slack-go/slack/messageID.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'vendor/github.com/slack-go/slack/messageID.go') 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) } -- cgit v1.2.3