From 0ea90952bdac100bde3149fa2a7818ba7af943b4 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 22 Mar 2024 17:00:10 +0100 Subject: pkg/fuzzer: remove async priority queue operations We don't need them. --- pkg/fuzzer/prio_queue.go | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'pkg/fuzzer/prio_queue.go') diff --git a/pkg/fuzzer/prio_queue.go b/pkg/fuzzer/prio_queue.go index ea8f448c9..cb35cebf7 100644 --- a/pkg/fuzzer/prio_queue.go +++ b/pkg/fuzzer/prio_queue.go @@ -24,41 +24,28 @@ func (p priority) greaterThan(other priority) bool { type priorityQueue[T any] struct { impl priorityQueueImpl[T] - c *sync.Cond + mu sync.RWMutex } func makePriorityQueue[T any]() *priorityQueue[T] { - return &priorityQueue[T]{ - c: sync.NewCond(&sync.Mutex{}), - } + return &priorityQueue[T]{} } func (pq *priorityQueue[T]) Len() int { - pq.c.L.Lock() - defer pq.c.L.Unlock() + pq.mu.RLock() + defer pq.mu.RUnlock() return pq.impl.Len() } func (pq *priorityQueue[T]) push(item *priorityQueueItem[T]) { - pq.c.L.Lock() - defer pq.c.L.Unlock() + pq.mu.Lock() + defer pq.mu.Unlock() heap.Push(&pq.impl, item) - pq.c.Signal() -} - -// pop() blocks until there's input. -func (pq *priorityQueue[T]) pop() *priorityQueueItem[T] { - pq.c.L.Lock() - defer pq.c.L.Unlock() - for pq.impl.Len() == 0 { - pq.c.Wait() - } - return heap.Pop(&pq.impl).(*priorityQueueItem[T]) } func (pq *priorityQueue[T]) tryPop() *priorityQueueItem[T] { - pq.c.L.Lock() - defer pq.c.L.Unlock() + pq.mu.Lock() + defer pq.mu.Unlock() if len(pq.impl) == 0 { return nil } -- cgit mrf-deployment