Documentation ¶
Overview ¶
This package provides a priority queue implementation and scaffold interfaces.
Copyright (C) 2011 by Krzysztof Kowalik <chris@nu7hat.ch>
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface {
Less(other interface{}) bool
}
Only Items implementing this interface can be enqueued on the priority queue.
type Queue ¶
Queue is a threadsafe priority queue exchange. Here's a trivial example of usage:
q := pqueue.New(0) go func() { for { task := q.Dequeue() println(task.(*CustomTask).Name) } }() for i := 0; i < 100; i := 1 { task := CustomTask{Name: "foo", priority: rand.Intn(10)} q.Enqueue(&task) }
func New ¶
New creates and initializes a new priority queue, taking a limit as a parameter. If 0 given, then queue will be unlimited.
func (*Queue) ChangeLimit ¶
Safely changes enqueued Items limit. When limit is set to 0, then queue is unlimited.
func (*Queue) Dequeue ¶
Dequeue takes an item from the queue. If queue is empty then should block waiting for at least one item.
Click to show internal directories.
Click to hide internal directories.