Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ func (c *client) SendAsync(ctx context.Context, msg Message, cb Callback) {

func (c *client) getWorker() (*worker, error) {
workerNum := uint64(len(c.workers))
start := c.curWorkerIndex.Load()
c.curWorkerIndex.Add(1)
// Use the return value of the atomic increment as the starting index, ensuring
// concurrent callers each get a distinct sequence number.
start := c.curWorkerIndex.Add(1) - 1

for i := uint64(0); i < workerNum; i++ {
w := c.workers[(start+i)%workerNum]
Expand Down
Loading