{"id":18150054,"url":"https://github.com/sysulq/goroutine-pool","last_synced_at":"2025-04-15T11:13:37.328Z","repository":{"id":57487320,"uuid":"118062625","full_name":"sysulq/goroutine-pool","owner":"sysulq","description":"A simple goroutine pool which can create and release goroutine dynamically, inspired by fasthttp.","archived":false,"fork":false,"pushed_at":"2024-11-19T02:38:08.000Z","size":40,"stargazers_count":35,"open_issues_count":0,"forks_count":7,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-15T11:13:21.228Z","etag":null,"topics":["fasthttp","golang","goroutine","goroutine-pool","pool"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/hnlq715/goroutine-pool","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/sysulq.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}},"created_at":"2018-01-19T01:56:58.000Z","updated_at":"2024-11-19T02:38:04.000Z","dependencies_parsed_at":"2024-02-02T09:08:06.123Z","dependency_job_id":"249f69f3-578e-4322-a5a0-09e2f2c9fb0c","html_url":"https://github.com/sysulq/goroutine-pool","commit_stats":null,"previous_names":["sysulq/goroutine-pool","hnlq715/goroutine-pool"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysulq%2Fgoroutine-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysulq%2Fgoroutine-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysulq%2Fgoroutine-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysulq%2Fgoroutine-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysulq","download_url":"https://codeload.github.com/sysulq/goroutine-pool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249058384,"owners_count":21205911,"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":["fasthttp","golang","goroutine","goroutine-pool","pool"],"created_at":"2024-11-02T00:07:20.264Z","updated_at":"2025-04-15T11:13:37.308Z","avatar_url":"https://github.com/sysulq.png","language":"Go","readme":"# goroutine-pool\n[![Go](https://github.com/sysulq/goroutine-pool/actions/workflows/go.yml/badge.svg)](https://github.com/sysulq/goroutine-pool/actions/workflows/go.yml)\n[![Coverage](https://codecov.io/gh/sysulq/goroutine-pool/branch/master/graph/badge.svg)](https://codecov.io/gh/sysulq/goroutine-pool)\n\nA simple goroutine pool which can create and release goroutine dynamically, inspired by fasthttp.\n\n# install\n```\ngo get -u -v github.com/sysulq/goroutine-pool\n```\n# example\n```\npackage main\n\nimport (\n\t\"fmt\"\n\tpool \"github.com/sysulq/goroutine-pool\"\n\t\"sync\"\n)\n\nfunc main() {\n\twg := sync.WaitGroup{}\n\tfor i := 0; i \u003c 5; i++ {\n\t\twg.Add(1)\n\t\tpool.Go(func() {\n\t\t\tfmt.Println(i)\n\t\t\twg.Done()\n\t\t})\n\t}\n\twg.Wait()\n\tfmt.Println()\n\n\tfor i := 0; i \u003c 5; i++ {\n\t\twg.Add(1)\n\t\tn := i\n\t\tpool.Go(func() {\n\t\t\tfmt.Println(n)\n\t\t\twg.Done()\n\t\t})\n\t}\n\twg.Wait()\n}\n```\n\n```\n$ go run main.go\n5\n5\n5\n5\n5\n\n4\n1\n0\n2\n3\n```\n\n# benchmarks\n\n## With Wait\n```\nRunning tool: D:\\Go\\bin\\go.exe test -benchmem -run=^$ workerpool -bench ^BenchmarkGoroutine$\n\ngoos: windows\ngoarch: amd64\npkg: workerpool\nBenchmarkGoroutine-4   \t    1000\t   1634621 ns/op\t      65 B/op\t       1 allocs/op\nPASS\nok  \tworkerpool\t2.047s\nSuccess: Benchmarks passed.\n```\n\n```\nRunning tool: D:\\Go\\bin\\go.exe test -benchmem -run=^$ workerpool -bench ^BenchmarkPool$\n\ngoos: windows\ngoarch: amd64\npkg: workerpool\nBenchmarkPool-4   \t    2000\t   1146818 ns/op\t      17 B/op\t       1 allocs/op\nPASS\nok  \tworkerpool\t2.702s\nSuccess: Benchmarks passed.\n```\n\n## Without Wait\n\n### cpu run at 100%\n```\nRunning tool: D:\\Go\\bin\\go.exe test -benchmem -run=^$ workerpool -bench ^BenchmarkGoroutineWithoutWait$\n\ngoos: windows\ngoarch: amd64\npkg: workerpool\nBenchmarkGoroutineWithoutWait-4   \t 1000000\t      4556 ns/op\t     517 B/op\t       1 allocs/op\nPASS\nok  \tworkerpool\t5.649s\nSuccess: Benchmarks passed.\n```\n\n### cpu relatively low\n\n```\nRunning tool: D:\\Go\\bin\\go.exe test -benchmem -run=^$ workerpool -bench ^BenchmarkPoolWithoutWait$\n\ngoos: windows\ngoarch: amd64\npkg: workerpool\nBenchmarkPoolWithoutWait-4   \t10000000\t       144 ns/op\t       3 B/op\t       0 allocs/op\nPASS\nok  \tworkerpool\t4.812s\nSuccess: Benchmarks passed.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysulq%2Fgoroutine-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysulq%2Fgoroutine-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysulq%2Fgoroutine-pool/lists"}