{"id":28554718,"url":"https://github.com/floraison/stagnum","last_synced_at":"2026-02-13T05:02:31.257Z","repository":{"id":280574083,"uuid":"942466783","full_name":"floraison/stagnum","owner":"floraison","description":"a stupid work thread pool","archived":false,"fork":false,"pushed_at":"2025-03-07T02:30:06.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-15T01:42:46.268Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/floraison.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2025-03-04T06:35:29.000Z","updated_at":"2025-03-07T02:30:09.000Z","dependencies_parsed_at":"2025-03-04T06:45:26.977Z","dependency_job_id":null,"html_url":"https://github.com/floraison/stagnum","commit_stats":null,"previous_names":["floraison/stagnum"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/floraison/stagnum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floraison%2Fstagnum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floraison%2Fstagnum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floraison%2Fstagnum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floraison%2Fstagnum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floraison","download_url":"https://codeload.github.com/floraison/stagnum/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floraison%2Fstagnum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29396847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T04:26:15.637Z","status":"ssl_error","status_checked_at":"2026-02-13T04:16:29.732Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2025-06-10T05:06:59.439Z","updated_at":"2026-02-13T05:02:31.253Z","avatar_url":"https://github.com/floraison.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# stagnum\n\nA stupid Ruby worker pool based on `Thread` and `Thread::Queue`.\n\n```ruby\npool = Stagnum::Pool.new('pool-zero', 4)\n  #\n  # 4 worker threads to service the enqueued jobs\n\nq = Stagnum::DoneQueue.new\n  #\n  # a queue shared by a group of jobs to enqueue\n\n30.times do |i|\n\n  pool.enqueue(q, { i: i }) do |d|\n\n    sleep(rand)\n\n    d[:tname] = Thread.current.name\n  end\nend\n\nsuccesses, failures = q.pop_all\n  #\n  # Stagnum::DoneQueue extends Thread::Queue\n  # but has a #pop_all convenience method\n\npp successes\n  #\n  # ==\u003e\n  #\n  # [[:success, {i: 0, tname: \"pool-zero__0\"}],\n  #  [:success, {i: 3, tname: \"pool-zero__3\"}],\n  #  [:success, {i: 1, tname: \"pool-zero__1\"}],\n  #  [:success, {i: 2, tname: \"pool-zero__2\"}],\n  #  [:success, {i: 7, tname: \"pool-zero__2\"}],\n  #  [:success, {i: 5, tname: \"pool-zero__3\"}],\n  #  [:success, {i: 9, tname: \"pool-zero__3\"}],\n  #  [:success, {i: 6, tname: \"pool-zero__1\"}],\n  #  [:success, {i: 4, tname: \"pool-zero__0\"}],\n  #  [:success, {i: 8, tname: \"pool-zero__2\"}]]\n```\n\nOne can use `Thread::Queue` instead of `Stagnum::DoneQueue`, but `DoneQueue` provides a `#pop_all`.\n\n`Stagnum::DoneQueue` also has `#on_success` and `#on_failure` (and `#on_pop` methods:\n\n```ruby\npool = Stagnum::Pool.new('pool-zero', 4)\n\ns, f = [], []\n\nq = Stagnum::DoneQueue.new\nq.on_success do |r|\n  s \u003c\u003c r\nend\nq.on_failure do |r|\n  f \u003c\u003c r\nend\n\n30.times do |i|\n\n  pool.enqueue(q, { i: i }) do |d|\n    sleep(rand)\n    d[:tname] = Thread.current.name\n  end\nend\n\nq.pop_all\n\n# ...\n```\n\n## LICENSE\n\nMIT, see [LICENSE.txt](LICENSE.txt)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloraison%2Fstagnum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloraison%2Fstagnum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloraison%2Fstagnum/lists"}