{"id":49339462,"url":"https://github.com/htrmc/zig-concurrent-queue","last_synced_at":"2026-04-27T03:03:04.273Z","repository":{"id":345559802,"uuid":"1186443443","full_name":"HTRMC/zig-concurrent-queue","owner":"HTRMC","description":"Lock-free multi-producer multi-consumer concurrent queue for Zig. Block-based, zero-lock design.","archived":false,"fork":false,"pushed_at":"2026-03-19T23:57:56.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-20T08:23:11.165Z","etag":null,"topics":["concurrent-queue","data-structures","lock-free","mpmc","multi-producer-multi-consumer","zig"],"latest_commit_sha":null,"homepage":null,"language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HTRMC.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-19T16:21:38.000Z","updated_at":"2026-03-19T23:57:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/HTRMC/zig-concurrent-queue","commit_stats":null,"previous_names":["htrmc/zig-concurrent-queue"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/HTRMC/zig-concurrent-queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HTRMC%2Fzig-concurrent-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HTRMC%2Fzig-concurrent-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HTRMC%2Fzig-concurrent-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HTRMC%2Fzig-concurrent-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HTRMC","download_url":"https://codeload.github.com/HTRMC/zig-concurrent-queue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HTRMC%2Fzig-concurrent-queue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32320686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"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":["concurrent-queue","data-structures","lock-free","mpmc","multi-producer-multi-consumer","zig"],"created_at":"2026-04-27T03:02:53.792Z","updated_at":"2026-04-27T03:03:04.259Z","avatar_url":"https://github.com/HTRMC.png","language":"Zig","readme":"# zig-concurrent-queue\n\nA lock-free, multi-producer multi-consumer concurrent queue written in Zig.\n\nBlock-based storage, per-producer sub-queues, no locks anywhere.\nBuilt with Zig's comptime generics and first-class atomics.\n\n## Features\n\n- Single and bulk enqueue/dequeue\n- Explicit producer and consumer tokens for best throughput\n- Token-less path via thread-local implicit producers\n- `tryEnqueue` for zero-allocation enqueue (only uses pre-allocated blocks)\n- `sizeApprox()` for approximate element count\n- Pre-allocation via `initWithCapacity`\n- Producer-local block reuse (circular chain, avoids global free list in steady state)\n- Reference-counted lock-free free list for block recycling\n- Block-index for O(1) block lookup during dequeue\n- `BlockingConcurrentQueue` with `waitDequeue` (spins then blocks via condition variable)\n\n## Quick start\n\nRequires **Zig 0.15+**.\n\n```bash\nzig build test\nzig build bench --\nzig build asm   # =\u003e zig-out/asm/concurrent_queue.s\n```\n\n## Usage\n\n```zig\nconst queue = @import(\"concurrent-queue\");\nconst ConcurrentQueue = queue.ConcurrentQueue;\n\nconst Q = ConcurrentQueue(u64, .{});\nvar q = Q.init(allocator);\n// or pre-allocate: var q = try Q.initWithCapacity(allocator, 1024);\ndefer q.deinit();\n\nvar ptok = try q.makeProducerToken();\ndefer ptok.deinit();\nvar ctok = q.makeConsumerToken();\n\n// single\ntry q.enqueue(\u0026ptok, 42);\nif (q.tryDequeue(\u0026ctok)) |value| _ = value;\n\n// bulk\nvar items = [_]u64{ 1, 2, 3 };\n_ = try q.enqueueBulk(\u0026ptok, \u0026items);\nvar out: [3]u64 = undefined;\n_ = q.tryDequeueBulk(\u0026ctok, \u0026out);\n\n// zero-allocation (only succeeds if pre-allocated space exists)\n_ = q.tryEnqueue(\u0026ptok, 99);\n\n// blocking variant\nconst BlockingQ = queue.BlockingConcurrentQueue(u64, .{});\nvar bq = BlockingQ.init(allocator);\ndefer bq.deinit();\n// bq.waitDequeue(\u0026ctok) blocks until an item is available\n```\n\n## Configuration\n\n```zig\nconst Q = ConcurrentQueue(MyStruct, .{\n    .block_size = 64,\n    .explicit_consumer_consumption_quota = 512,\n});\n```\n\n## License\n\nBSD-2-Clause.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtrmc%2Fzig-concurrent-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhtrmc%2Fzig-concurrent-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtrmc%2Fzig-concurrent-queue/lists"}