Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gammazero/channelqueue
queue that can be used like buffered channel with any capacity
https://github.com/gammazero/channelqueue
buffered channel deque queue ring ring-buffer synchronized
Last synced: 11 days ago
JSON representation
queue that can be used like buffered channel with any capacity
- Host: GitHub
- URL: https://github.com/gammazero/channelqueue
- Owner: gammazero
- License: mit
- Created: 2020-02-04T19:45:07.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-08-04T02:12:04.000Z (over 1 year ago)
- Last Synced: 2024-10-10T13:13:32.730Z (28 days ago)
- Topics: buffered, channel, deque, queue, ring, ring-buffer, synchronized
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# channelqueue
[![GoDoc](https://pkg.go.dev/badge/github.com/gammazero/channelqueue)](https://pkg.go.dev/github.com/gammazero/channelqueue)
[![Build Status](https://github.com/gammazero/channelqueue/actions/workflows/go.yml/badge.svg)](https://github.com/gammazero/channelqueue/actions/workflows/go.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/gammazero/channelqueue)](https://goreportcard.com/report/github.com/gammazero/channelqueue)
[![codecov](https://codecov.io/gh/gammazero/channelqueue/branch/master/graph/badge.svg)](https://codecov.io/gh/gammazero/channelqueue)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)Concurrently access a dynamic queue using channels.
ChannelQueue implements a queue that uses channels for input and output to provide concurrent access to a dynamically-sized queue. This allows the queue to be used like a channel, in a thread-safe manner. Closing the input channel closes the output channel when all queued items are read, consistent with channel behavior. In other words a ChannelQueue is a dynamically buffered channel with up to infinite capacity.
ChannelQueue also supports circular buffer behavior when created using `NewRing`. When the buffer is full, writing an additional item discards the oldest buffered item.
When specifying an unlimited buffer capacity use caution as the buffer is still limited by the resources available on the host system.
The ChannelQueue buffer auto-resizes according to the number of items buffered. For more information on the queue, see: https://github.com/gammazero/deque
ChannelQueue uses generics to contain items of the type specified. To create a ChannelQueue that holds a specific type, provide a type argument to `New`. For example:
```go
intChanQueue := channelqueue.New[int](1024)
stringChanQueue := channelqueue.New[string](-1)
```