{"id":28570995,"url":"https://github.com/mguludag/task","last_synced_at":"2025-06-10T18:14:58.571Z","repository":{"id":296686720,"uuid":"994147086","full_name":"mguludag/task","owner":"mguludag","description":"A generic, header-only C++ task wrapper that supports cancellation, continuations, and result retrieval via futures.","archived":false,"fork":false,"pushed_at":"2025-06-01T11:51:46.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-01T19:08:35.404Z","etag":null,"topics":["asynchronous","cpp","cpp11","cpp17","cpp20"],"latest_commit_sha":null,"homepage":"","language":"C++","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/mguludag.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":"2025-06-01T10:12:21.000Z","updated_at":"2025-06-01T11:55:41.000Z","dependencies_parsed_at":"2025-06-01T19:08:37.917Z","dependency_job_id":"eed88e03-4bf5-4f90-9703-fee6f2a218db","html_url":"https://github.com/mguludag/task","commit_stats":null,"previous_names":["mguludag/task"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguludag%2Ftask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguludag%2Ftask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguludag%2Ftask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguludag%2Ftask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mguludag","download_url":"https://codeload.github.com/mguludag/task/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguludag%2Ftask/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259123990,"owners_count":22808879,"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":["asynchronous","cpp","cpp11","cpp17","cpp20"],"created_at":"2025-06-10T18:14:54.796Z","updated_at":"2025-06-10T18:14:58.560Z","avatar_url":"https://github.com/mguludag.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# task\n\nA generic, header-only C++ task wrapper that supports cancellation, continuations, and result retrieval via futures.\n\n## Features\n\n- **Composable asynchronous tasks**: Chain tasks using `.then()`.\n- **Cancellation support**: Cancel tasks before execution.\n- **Continuation support**: Attach continuations to tasks for flexible workflows.\n- **Future-based result access**: Retrieve results using `std::shared_future`.\n- **Explicit invocation**: Control when tasks start via an invoker object.\n- **Header-only**: Just include the headers, no linking required.\n\n## Getting Started\n\n### Installation\n\nThis library is header-only. You can use one of the following methods:\n\n#### 1. Manual Copy\n\nCopy the contents of the `include/` directory into your project.\n\n#### 2. CMake (find_package)\n\n```cmake\nfind_package(task CONFIG REQUIRED)\ntarget_link_libraries(your_target PRIVATE mgutility::task)\n```\n\n#### 3. CMake FetchContent\n\n```cmake\ninclude(FetchContent)\nFetchContent_Declare(\n    task\n    GIT_REPOSITORY https://github.com/mguludag/task.git\n    GIT_TAG        main\n)\nFetchContent_MakeAvailable(task)\ntarget_link_libraries(your_target PRIVATE mgutility::task)\n```\n\n### Usage\n\n```cpp\n#include \u003cmgutility/task.hpp\u003e\n#include \u003ciostream\u003e\n\nint main() {\n    mgutility::task\u003cint\u003e t([] { return 42; });\n    auto t2 = t.then([](std::shared_future\u003cint\u003e f) { return f.get() + 1; });\n\n    t.get_invoker()(); // Start the chain\n\n    int result = t2.get();\n    std::cout \u003c\u003c \"Result: \" \u003c\u003c result \u003c\u003c std::endl; // Output: Result: 43\n}\n```\n\n#### With Thread Pools (e.g., Asio)\n\n```cpp\n#include \u003casio/thread_pool.hpp\u003e\n#include \u003casio/post.hpp\u003e\n#include \u003cmgutility/task.hpp\u003e\n\nasio::thread_pool pool(4);\nmgutility::task\u003cint\u003e t([] { return 42; });\nauto t2 = t.then([](std::shared_future\u003cint\u003e f) { return f.get() + 1; });\nasio::post(pool, t.get_invoker());\nint result = t2.get();\npool.join();\n```\n\n## API Overview\n\nSee [include/task.hpp](include/mgutility/task.hpp) for full documentation.\n\n- [`mgutility::task`](include/mgutility/task.hpp): Main task class template.\n- `task::then()`: Attach a continuation.\n- `task::cancel()`: Cancel the task.\n- `task::get_future()`: Get the shared future.\n- `task::get_invoker()`: Get an invoker to start the task.\n\n## Requirements\n\n- C++11 or newer\n\n## License\n\nMIT License. See [LICENSE](LICENSE) for details.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmguludag%2Ftask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmguludag%2Ftask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmguludag%2Ftask/lists"}