A Go package offering thread-safe generic implementations of BlockingQueue, PriorityQueue, CircularQueue, and Linked Queue.
Queue is a Go package that provides multiple thread-safe, generic queue implementations, including BlockingQueue, PriorityQueue, CircularQueue, and Linked Queue. It solves the need for efficient, concurrent data structures in Go applications by offering a consistent API and robust synchronization.
Go developers building applications that require concurrent data handling, such as task schedulers, message brokers, or systems needing priority-based or fixed-size buffering.
Developers choose this package for its thread-safe designs, generic type support, and variety of queue implementations—all through a unified interface, making it a reliable alternative to building custom queue logic from scratch.
⏪️ Go package providing multiple queue implementations. Developed in a thread-safe generic way.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
All implementations are built for concurrent use, with BlockingQueue using sync.Cond for synchronization, ensuring safe data handling in multi-goroutine environments as emphasized in the README.
A unified Queue interface allows easy swapping of queue types without code changes, demonstrated in the usage examples where all queues implement the same methods like Offer and Get.
Offers four specialized implementations: BlockingQueue for FIFO with blocking ops, PriorityQueue with custom comparator, CircularQueue for fixed-size buffering, and Linked Queue for O(1) operations, catering to diverse needs.
Supports Go generics for type-safe usage with any comparable data type, as defined in the Queue[T comparable] interface, reducing runtime errors.
Benchmarks show efficient operations, e.g., Linked Queue Peek at 0.4179 ns/op and low latency for other queues, indicating suitability for high-throughput scenarios.
Lacks persistence features; all queue data is volatile and lost on application restart, which may not suit use cases requiring durability like task queues in crash-recovery systems.
Benchmarks reveal that Linked Queue operations involve memory allocations (1 alloc/op for Offer and Get_Offer), potentially impacting garbage collection in allocation-sensitive environments.
The Queue interface requires T comparable, restricting usage to types with defined equality, which might exclude complex custom structs without implementing comparison logic.
BlockingQueue's blocking methods don't include timeout mechanisms out of the box, requiring additional code for scenarios where operations need to time out, as not mentioned in the README.