{"id":15497476,"url":"https://github.com/heapwolf/cpp-libasync","last_synced_at":"2025-04-22T21:43:27.379Z","repository":{"id":32194549,"uuid":"35768109","full_name":"heapwolf/cpp-libasync","owner":"heapwolf","description":"general purpose asynchronous control flow helpers on thread-safe data structures","archived":false,"fork":false,"pushed_at":"2015-05-17T17:13:11.000Z","size":136,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T19:11:09.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heapwolf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-17T13:56:13.000Z","updated_at":"2016-04-09T01:16:25.000Z","dependencies_parsed_at":"2022-09-19T11:02:34.734Z","dependency_job_id":null,"html_url":"https://github.com/heapwolf/cpp-libasync","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/heapwolf%2Fcpp-libasync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fcpp-libasync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fcpp-libasync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Fcpp-libasync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heapwolf","download_url":"https://codeload.github.com/heapwolf/cpp-libasync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250330319,"owners_count":21412963,"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":[],"created_at":"2024-10-02T08:38:24.684Z","updated_at":"2025-04-22T21:43:27.354Z","avatar_url":"https://github.com/heapwolf.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SYNOPSIS\nThis is an idea for some general purpose asynchronous control flow helpers\nthat write to a data structure of the given input type in a thread-safe way.\n\n# BUILD\n```\nc++ test.cc -o test -std=c++1y\n```\n\n# METHODS\n\n## EACH PARALLEL\nRun the function in parallel on each of the array values, each without \nwaiting until the previous function has completed. The calling thread \nwaits until all tasks have completed.\n \n```cpp\n#include \"libsync.h\"\n\n//\n// any arbitrary iterable\n//\nvector\u003cint\u003e arr { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };\n\nauto results = libasync.eachParallel(arr, [\u0026](auto value, auto push) {\n  // do something async\n  push(value);\n});\n\nfor(auto \u0026el : results)\n  cout \u003c\u003c el \u003c\u003c endl;\n```\n\n## EACH\nRun the function on each item in the array in series, each one running\nonce the previous function has completed. For each item the lambda is\nexecuted in a separate thread. If `push` is not called, the iteration \nwill stop. You can also terminate flow by passing `nullptr` as the \nvalue to `push`.\n\n```cpp\nvector\u003cstring\u003e arr { \"foo\", \"bar\", \"bazz\" };\n\nauto results = libasync.each(arr, [\u0026](auto value, auto push) {\n  push(value);\n});\n\nfor (auto \u0026el : results)\n  cout \u003c\u003c el \u003c\u003c endl;\n```\n\n## ERRORS\nMethods can be wrapped in try catches! The thread will bubble the\nexception back up to the caller.\n\n```cpp\ntry {\n\n  vector\u003cstring\u003e arr { \"foo\", \"bar\", \"bazz\" };\n\n  libasync.each(arr, [\u0026](auto value, auto push) {\n    if (value == \"bar\") throw runtime_error(\"oops\");\n    push(value);\n  });\n\n}\ncatch(const std::exception\u0026 ex) {\n  cout \u003c\u003c ex.what() \u003c\u003c endl;\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheapwolf%2Fcpp-libasync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheapwolf%2Fcpp-libasync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheapwolf%2Fcpp-libasync/lists"}