{"id":15490531,"url":"https://github.com/theodesp/blockingqueues","last_synced_at":"2025-09-21T21:50:15.586Z","repository":{"id":57488737,"uuid":"114998057","full_name":"theodesp/blockingQueues","owner":"theodesp","description":"Simple, performant, goroutine safe queues, useful as resource pools or job queues. ","archived":false,"fork":false,"pushed_at":"2017-12-30T19:29:39.000Z","size":67,"stargazers_count":24,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-22T19:08:59.342Z","etag":null,"topics":["arrays","blocking-queue","data-structures","golang-library","resource-pool"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/theodesp/blockingQueues","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theodesp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-21T11:22:43.000Z","updated_at":"2024-10-08T20:14:26.000Z","dependencies_parsed_at":"2022-08-29T11:00:52.178Z","dependency_job_id":null,"html_url":"https://github.com/theodesp/blockingQueues","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/theodesp/blockingQueues","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2FblockingQueues","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2FblockingQueues/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2FblockingQueues/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2FblockingQueues/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theodesp","download_url":"https://codeload.github.com/theodesp/blockingQueues/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2FblockingQueues/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276312967,"owners_count":25620626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-21T02:00:07.055Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arrays","blocking-queue","data-structures","golang-library","resource-pool"],"created_at":"2024-10-02T07:21:56.765Z","updated_at":"2025-09-21T21:50:15.567Z","avatar_url":"https://github.com/theodesp.png","language":"Go","readme":"Blocking Queues\n---\n\u003ca href=\"https://godoc.org/github.com/theodesp/blockingQueues\"\u003e\n\u003cimg src=\"https://godoc.org/github.com/theodesp/blockingQueues?status.svg\" alt=\"GoDoc\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://opensource.org/licenses/MIT\" rel=\"nofollow\"\u003e\n\u003cimg src=\"https://img.shields.io/github/license/mashape/apistatus.svg\" alt=\"License\"/\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://travis-ci.org/theodesp/blockingQueues\" rel=\"nofollow\"\u003e\n\u003cimg src=\"https://travis-ci.org/theodesp/blockingQueues.svg?branch=master\" /\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/theodesp/blockingQueues\"\u003e\n  \u003cimg src=\"https://codecov.io/gh/theodesp/blockingQueues/branch/master/graph/badge.svg\" /\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://ci.appveyor.com/project/theodesp/blockingqueues\" rel=\"nofollow\"\u003e\n  \u003cimg src=\"https://ci.appveyor.com/api/projects/status/7yiwtn68qmcj71xy?svg=true\" /\u003e\n\u003c/a\u003e\n\nBlocking Queues provides some simple, performant, goroutine safe queues useful as resource pools or job queues. \nThe primary focus is simplicity and high performance without sacrificing readability. In fact I tried to\nprovide good documentation on the code and some examples of usage.\n\n\n## Queues Provided\n* **ArrayBlockingQueue**: A bounded blocking queue backed by a slice\n* **LinkedBlockingQueue**: A bounded blocking queue backed by a container/list\n* **ConcurrentRingBuffer**: A bounded lock-free queue backed by a slice\n\n## Installation\n```go\ngo get -u github.com/theodesp/blockingQueues\n```\n\n## Usage\n\nNon blocking api\n```go\nqueue, _ := NewArrayBlockingQueue(2)\nres, _ := queue.Push(1)\nres, _ := queue.Push(2)\nres, err := queue.Push(3) // err is not Nil as queue is full\nres, err := queue.Pop()\nres, err := queue.Pop()\nres, err := queue.Pop() // err is not Nil as queue is empty\n```\n\nBlocking api\n```go\nqueue, _ := NewArrayBlockingQueue(2)\nres, _ := queue.Put(1)\nres, _ := queue.Put(2)\nres, err := queue.Put(3) // Will block the current goroutine\n\n// In another goroutine\nres, err := queue.Get() // Will unblock the first goroutine and add the last item\nres, err := queue.Get()\nres, err := queue.Get()\nres, err := queue.Get() // Will block the current goroutine\n```\n\nFull API Documentation: \n[https://godoc.org/github.com/theodesp/blockingQueues](https://godoc.org/github.com/theodesp/blockingQueues)\n\n## Benchmarks\nUsing:\n  ```text\n  Model Name:\tMacBook Pro\n  Model Identifier:\tMacBookPro12,1\n  Processor Name:\tIntel Core i7\n  Processor Speed:\t3.1 GHz\n  Number of Processors:\t1\n  Total Number of Cores:\t2\n  L2 Cache (per Core):\t256 KB\n  L3 Cache:\t4 MB\n  Memory:\t16 GB\n```\n#### ArrayBlockingQueue\nSimple operations - no goroutines\n\n```text\nArrayBlockingQueueSuite.BenchmarkPeek     100000000               21.0 ns/op\nArrayBlockingQueueSuite.BenchmarkPop      100000000               20.7 ns/op\nArrayBlockingQueueSuite.BenchmarkPopOverflow       100000000               20.8 ns/op\nArrayBlockingQueueSuite.BenchmarkPush      50000000                38.9 ns/op\nArrayBlockingQueueSuite.BenchmarkPushOverflow      50000000                39.0 ns/op\n```\n\nMultiple Goroutines - Different ratio of readers/writers - Size of Queue is 1024 items\n\n```text\nArrayBlockingQueueSuite.BenchmarkPut1to1   10000000               169 ns/op\nArrayBlockingQueueSuite.BenchmarkPut2to2    5000000               508 ns/op\nArrayBlockingQueueSuite.BenchmarkPut4to4    1000000              1222 ns/op\n```\nThe last test is slower as the number of goroutines are double of the available logic cores\nand it is expected to go slower because of the context switching.\n\n```text\nArrayBlockingQueueSuite.BenchmarkPut1to3   5000000               837 ns/op\nArrayBlockingQueueSuite.BenchmarkPut1to4   1000000              1126 ns/op\nArrayBlockingQueueSuite.BenchmarkPut2to1   5000000               476 ns/op\nArrayBlockingQueueSuite.BenchmarkPut2to3   2000000               799 ns/op\nArrayBlockingQueueSuite.BenchmarkPut3to2   2000000               816 ns/op\nArrayBlockingQueueSuite.BenchmarkPut4to1   1000000              1239 ns/op\n```\nHaving a different ratio of readers and writers introduce the same amount of latency.\n\n#### LinkedBlockingQueue\n```text\nLinkedBlockingQueueSuite.BenchmarkPeek       100000000               21.4 ns/op\nLinkedBlockingQueueSuite.BenchmarkPop100000000               24.4 ns/op\nLinkedBlockingQueueSuite.BenchmarkPopOverflow        100000000               23.4 ns/op\nLinkedBlockingQueueSuite.BenchmarkPush       50000000                47.3 ns/op\nLinkedBlockingQueueSuite.BenchmarkPushOverflow       50000000                42.1 ns/op\nLinkedBlockingQueueSuite.BenchmarkPut1to1    10000000               246 ns/op\nLinkedBlockingQueueSuite.BenchmarkPut1to3     2000000               930 ns/op\nLinkedBlockingQueueSuite.BenchmarkPut1to4     1000000              1496 ns/op\nLinkedBlockingQueueSuite.BenchmarkPut2to1     5000000               578 ns/op\nLinkedBlockingQueueSuite.BenchmarkPut2to2     5000000               560 ns/op\nLinkedBlockingQueueSuite.BenchmarkPut2to3     2000000              1053 ns/op\nLinkedBlockingQueueSuite.BenchmarkPut3to2     2000000              1041 ns/op\nLinkedBlockingQueueSuite.BenchmarkPut4to1     1000000              1488 ns/op\nLinkedBlockingQueueSuite.BenchmarkPut4to4     1000000              1451 ns/op\n```\n\n#### ConcurrentRingBuffer\nTest\n```text\nConcurrentRingBufferSuite.BenchmarkRingBuffer1to1        20000000                85.7 ns/op\nConcurrentRingBufferSuite.BenchmarkRingBuffer1to3         1000000              2793 ns/op\nConcurrentRingBufferSuite.BenchmarkRingBuffer1to4          500000              5501 ns/op\nConcurrentRingBufferSuite.BenchmarkRingBuffer2to1         5000000               465 ns/op\nConcurrentRingBufferSuite.BenchmarkRingBuffer2to2         5000000               474 ns/op\nConcurrentRingBufferSuite.BenchmarkRingBuffer2to3         1000000              2640 ns/op\nConcurrentRingBufferSuite.BenchmarkRingBuffer3to2         1000000              2766 ns/op\nConcurrentRingBufferSuite.BenchmarkRingBuffer4to1         1000000              5411 ns/op\nConcurrentRingBufferSuite.BenchmarkRingBuffer4to4          500000              5370 ns/op\n\n```\n\n## LICENCE\nCopyright © 2017 Theo Despoudis MIT license\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fblockingqueues","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheodesp%2Fblockingqueues","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fblockingqueues/lists"}