shutdown follower when leader stops

This commit is contained in:
chrislu
2024-04-01 22:32:30 -07:00
parent f07875e8e1
commit d935f70e3c
2 changed files with 120 additions and 6 deletions

View File

@@ -117,6 +117,19 @@ func (q *BufferedQueue[T]) Dequeue() (T, bool) {
return job, true
}
func (q *BufferedQueue[T]) PeekHead() (T, bool) {
q.mutex.Lock()
defer q.mutex.Unlock()
if q.count <= 0 {
var a T
return a, false
}
job := q.head.items[q.head.headIndex]
return job, true
}
// Size returns the number of items in the queue
func (q *BufferedQueue[T]) Size() int {
q.mutex.Lock()