Skip to content

Commit

Permalink
Switch message dequeue to LIFO
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Aug 8, 2018
1 parent 12f733f commit 275689a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,16 @@ func (m *Memberlist) handleCommand(buf []byte, from net.Addr, timestamp time.Tim
}
}

// getNextMessage returns the next message to process in priority order
// getNextMessage returns the next message to process in priority order, using LIFO
func (m *Memberlist) getNextMessage() (msgHandoff, bool) {
m.msgQueueLock.Lock()
defer m.msgQueueLock.Unlock()

if el := m.highPriorityMsgQueue.Front(); el != nil {
if el := m.highPriorityMsgQueue.Back(); el != nil {
m.highPriorityMsgQueue.Remove(el)
msg := el.Value.(msgHandoff)
return msg, true
} else if el := m.lowPriorityMsgQueue.Front(); el != nil {
} else if el := m.lowPriorityMsgQueue.Back(); el != nil {
m.lowPriorityMsgQueue.Remove(el)
msg := el.Value.(msgHandoff)
return msg, true
Expand Down

0 comments on commit 275689a

Please sign in to comment.