{"id":21288152,"url":"https://github.com/karitham/wq","last_synced_at":"2025-03-15T15:27:20.547Z","repository":{"id":56855614,"uuid":"526299335","full_name":"karitham/wq","owner":"karitham","description":"work queue","archived":false,"fork":false,"pushed_at":"2022-08-18T22:24:33.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T05:29:47.050Z","etag":null,"topics":["atomics","go","golang","multiplexing","work-queue"],"latest_commit_sha":null,"homepage":"","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/karitham.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":"2022-08-18T16:56:23.000Z","updated_at":"2022-08-18T17:09:20.000Z","dependencies_parsed_at":"2022-09-21T13:12:13.828Z","dependency_job_id":null,"html_url":"https://github.com/karitham/wq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karitham%2Fwq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karitham%2Fwq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karitham%2Fwq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karitham%2Fwq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karitham","download_url":"https://codeload.github.com/karitham/wq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243748541,"owners_count":20341701,"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","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":["atomics","go","golang","multiplexing","work-queue"],"created_at":"2024-11-21T12:18:59.823Z","updated_at":"2025-03-15T15:27:20.517Z","avatar_url":"https://github.com/karitham.png","language":"Go","readme":"# wq\n\nStupid lock-free work queue.\n\nThis was mostly an experiment, and hasn't been throughly tested, but should be equivalent or faster than a channel based one.\n\n```benchmark\n\u003e\u003e go test -benchmem -run=^$ -bench=. -benchtime=5s .\ngoos: linux\ngoarch: amd64\npkg: github.com/Karitham/wq\ncpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz\nBenchmarkQueue-8        52272778               120.6 ns/op             0 B/op          0 allocs/op\nBenchmarkChans-8        18827577               322.6 ns/op             0 B/op          0 allocs/op\nPASS\nok      github.com/Karitham/wq  13.076s\n```\n\nIt has the downside of requiring you to know your queue size ahead of time, which dictates the worker count.\n\nIt is also a busy queue, which works best if your producer are faster than your consumers.\n\n## Usage\n\n```go\nq := wq.New(func(v *int) { fmt.Println(*v) })\n\nfor i := 0; i \u003c 1000; i++ {\n    i := i // copy (else it would be a pointer to the same value)\n    q.EnQ(\u0026i) // enqueue i\n}\n\nq.Wait() // wait for all workers to be done\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaritham%2Fwq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaritham%2Fwq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaritham%2Fwq/lists"}