{"id":21327875,"url":"https://github.com/siddiqsoft/asynchrony","last_synced_at":"2026-04-28T06:04:39.469Z","repository":{"id":46541350,"uuid":"407301947","full_name":"SiddiqSoft/asynchrony","owner":"SiddiqSoft","description":"Classes to allow you to build asynchrony in your applications using standard C++ jthread, semaphore, deque","archived":false,"fork":false,"pushed_at":"2025-04-06T04:07:29.000Z","size":167,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-17T20:17:45.745Z","etag":null,"topics":["asynchronous-programming","cpp","cpp20","nuget","periodic-invocation","thread-pool","worker-pool"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SiddiqSoft.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}},"created_at":"2021-09-16T20:14:02.000Z","updated_at":"2025-04-04T06:56:47.000Z","dependencies_parsed_at":"2025-01-10T04:18:41.875Z","dependency_job_id":"21d7510a-d836-4fa6-b6cc-59b557630f63","html_url":"https://github.com/SiddiqSoft/asynchrony","commit_stats":{"total_commits":34,"total_committers":2,"mean_commits":17.0,"dds":"0.23529411764705888","last_synced_commit":"36e52c5a4a667f9ad632004724b12a54c97c2728"},"previous_names":["siddiqsoft/asynchrony","siddiqsoft/asynchrony-lib"],"tags_count":36,"template":false,"template_full_name":null,"purl":"pkg:github/SiddiqSoft/asynchrony","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2Fasynchrony","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2Fasynchrony/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2Fasynchrony/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2Fasynchrony/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SiddiqSoft","download_url":"https://codeload.github.com/SiddiqSoft/asynchrony/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SiddiqSoft%2Fasynchrony/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32196155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-23T15:28:30.493Z","status":"ssl_error","status_checked_at":"2026-04-23T15:28:29.972Z","response_time":53,"last_error":"SSL_read: 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":["asynchronous-programming","cpp","cpp20","nuget","periodic-invocation","thread-pool","worker-pool"],"created_at":"2024-11-21T21:20:12.395Z","updated_at":"2026-04-23T20:00:36.412Z","avatar_url":"https://github.com/SiddiqSoft.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"asynchrony : Add asynchrony to your apps\n-------------------------------------------\n\u003c!-- badges --\u003e\n[![Build Status](https://dev.azure.com/siddiqsoft/siddiqsoft/_apis/build/status/SiddiqSoft.asynchrony?branchName=main)](https://dev.azure.com/siddiqsoft/siddiqsoft/_build/latest?definitionId=17\u0026branchName=main)\n![](https://img.shields.io/nuget/v/SiddiqSoft.asynchrony)\n![](https://img.shields.io/github/v/tag/SiddiqSoft/asynchrony)\n![](https://img.shields.io/azure-devops/tests/siddiqsoft/siddiqsoft/17)\n\u003c!-- end badges --\u003e\n\n# Motivation\n- We needed to add asynchrony to our code.\n- The code here is a set of helpers that utilize the underlying deque, semaphore, mutex features found in std.\n- Be instructive while providing functional code\n- Use only C++20 standard code: jthread, deque, semaphore, barriers and latch\n\n# Usage\n\n\u003e Requires C++20 support!\n\u003e\n\u003e Specifically we require `jthread` and `stop_token` support which is unfortunately not available in the Apple Clang 16 version. This library works with gcc 14+ or MSVC 17+ or Clang 18+.\n\nRefer to the [documentation](https://siddiqsoft.github.io/asynchrony/) for details.\n\nThe library uses concepts to ensure the type `T` meets move construct requirements.\n\n## Single threaded worker\n\n```cpp\n#include \"siddiqsoft/simple_worker.hpp\"\n\n// Define your data\nstruct MyWork\n{\n   std::string urlDestination{};\n   std::string data{};\n   void operator()(){\n      magic_post_to(urlDestination, data);\n   }\n};\n\nvoid main()\n{\n   // Declare worker with our data type and the driver function.\n   siddiqsoft::simple_worker\u003cMyWork\u003e worker{[](auto\u0026 item){\n                                              // call the item's operator()\n                                              // to invoke actual work.\n                                              item();\n                                           }};\n   // Fire 100 items\n   for( int i=0; i \u003c 100; i++ )\n   {\n      // Queues into the single worker\n      worker.queue({std::format(\"https://localhost:443/test?iter={}\",i),\n                    \"hello-world\"});\n   }\n\n   // As the user, you must control the lifetime of the worker\n   // Trying to delete the worker will cause it to stop\n   // and abandon any items in the internal deque.\n   std::this_thread::sleep_for(1s);\n}\n\n```\n\n## Multi-threaded worker pool\n\n```cpp\n#include \"siddiqsoft/simple_pool.hpp\"\n\nvoid main()\n{\n   // Declare worker with our data type and the driver function.\n   siddiqsoft::simple_pool\u003cMyWork\u003e worker{[](auto\u0026 item){\n                                           // call the item's operator()\n                                           // to invoke actual work.\n                                           item();\n                                        }};\n   // Fire 100 items\n   for( int i=0; i \u003c 100; i++ )\n   {\n      // Queues into the single queue but multiple worker threads\n      // (defaults to CPU thread cout)\n      worker.queue({std::format(\"https://localhost:443/test?iter={}\",i),\n                    \"hello-world\"});\n   }\n\n   // As the user, you must control the lifetime of the worker\n   // Trying to delete the worker will cause it to stop\n   // and abandon any items in the internal deque.\n   std::this_thread::sleep_for(1s);\n}\n```\n\n\n## Multi-threaded roundrobin pool\n\n```cpp\n#include \"siddiqsoft/roundrobin_pool.hpp\"\n\nvoid main()\n{\n   // Declare worker with our data type and the driver function.\n   siddiqsoft::roundrobin_pool\u003cMyWork\u003e worker{[](auto\u0026 item){\n                                               // call the item's operator()\n                                               // to invoke actual work.\n                                               item();\n                                             }};\n   // Fire 100 items\n   for( int i=0; i \u003c 100; i++ )\n   {\n      // Queues into the thread pools individual queue by round-robin\n      // across the threads with simple counter.\n      // (defaults to CPU thread cout)\n      worker.queue({std::format(\"https://localhost:443/test?iter={}\",i),\n                    \"hello-world\"});\n   }\n\n   // As the user, you must control the lifetime of the worker\n   // Trying to delete the worker will cause it to stop\n   // and abandon any items in the internal deque.\n   std::this_thread::sleep_for(1s);\n}\n```\n\n## Resource Pool\n\nProvides a basic resource pool useful for keeping a pool of connection objects for the various threadpools to checkout/checkin.\n\n```cpp\nnamespace siddiqsoft {\n    template\u003ctypename T\u003e\n    class resource_pool {\n        public:\n        auto getCapacity();\n        [[nodiscard]] T checkout(); /* throw() */\n        void checkin(T\u0026\u0026 rsrc);\n    };\n}\n```\n\n## Implementation note\nIn order to use `std::jthread` on Clang 18 and Clang 19, we enable the compiler flag `\"CMAKE_CXX_FLAGS\": \"-fexperimental-library\"` in the CMakeLists.txt. This option will show up in your client library under Clang compilers.\n\n\u003cp align=\"right\"\u003e\n\u0026copy; 2021 Siddiq Software LLC. All rights reserved.\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddiqsoft%2Fasynchrony","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiddiqsoft%2Fasynchrony","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddiqsoft%2Fasynchrony/lists"}