From b5fb850d1bf3a8aa541cdd5dab400f688d5c9c87 Mon Sep 17 00:00:00 2001 From: Balint Gabor Date: Tue, 2 Jan 2018 17:12:15 +0100 Subject: [PATCH] Rename priorityqueues to priorityqueue again --- swarm/network/priorityqueue/priorityqueue.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/swarm/network/priorityqueue/priorityqueue.go b/swarm/network/priorityqueue/priorityqueue.go index d64124d6c2..2c6e3e52b0 100644 --- a/swarm/network/priorityqueue/priorityqueue.go +++ b/swarm/network/priorityqueue/priorityqueue.go @@ -1,4 +1,4 @@ -// package priority_queues implement a channel based priority queue +// package priority_queue implement a channel based priority queue // over arbitrary types. It provides an // an autopop loop applying a function to the items always respecting // their priority. The structure is only quasi consistent ie., if a lower @@ -7,7 +7,7 @@ // that there was any point where the lower priority item was present // but the higher was not -package priorityqueues +package priorityqueue import ( "context" @@ -21,26 +21,26 @@ var ( wakey = struct{}{} ) -// PriorityQueues is the basic structure -type PriorityQueues struct { +// PriorityQueue is the basic structure +type PriorityQueue struct { queues []chan interface{} wakeup chan struct{} } -// New is the constructor for PriorityQueues -func New(n int, l int) *PriorityQueues { +// New is the constructor for PriorityQueue +func New(n int, l int) *PriorityQueue { var queues = make([]chan interface{}, n) for i := range queues { queues[i] = make(chan interface{}, l) } - return &PriorityQueues{ + return &PriorityQueue{ queues: queues, wakeup: make(chan struct{}, 1), } } // Run is a forever loop popping items from the queues -func (pq *PriorityQueues) Run(ctx context.Context, f func(interface{})) { +func (pq *PriorityQueue) Run(ctx context.Context, f func(interface{})) { top := len(pq.queues) - 1 p := top q := pq.queues[p] @@ -70,7 +70,7 @@ READ: // Push pushes an item to the appropriate queue specified in the priority argument // if context is given it waits until either the item is pushed or the Context aborts // otherwise returns errContention if the queue is full -func (pq *PriorityQueues) Push(ctx context.Context, x interface{}, p int) error { +func (pq *PriorityQueue) Push(ctx context.Context, x interface{}, p int) error { if p < 0 || p >= len(pq.queues) { return errBadPriority }