// Package priorityq provides generic implementations of various concurrent, // prioritized queues. // // # Behavior // // All types of queues in this module act similarly to buffered Go channels. // // - They are bounded to a fixed capacity, set at construction. // - Closing and sending to an already-closed queue causes a panic. // - Receivers can continue getting items after closure, and can use a final // bool to determine when there are none remaining. // - They are safe for multiple concurrent senders and receivers. // // # Implementation // // All data structures in this module use [generics], introduced in Go 1.18. // // All of the concurrent data structures in this package use a [sync.Mutex] // and a few [sync.Cond] variables. // // [generics]: https://go.dev/blog/intro-generics package priorityq import ( "fmt" ) // ErrEmpty means that an operation failed because the queue was empty. var ErrEmpty error // ErrFull means that an operation failed because the queue was full. var ErrFull error // ErrClosed means that an operation failed because the queue was closed. var ErrClosed error func init() { ErrEmpty = fmt.Errorf("queue is empty") ErrFull = fmt.Errorf("queue is full") ErrClosed = fmt.Errorf("queue is closed") }