{"id":16795650,"url":"https://github.com/alanmcgovern/reusabletasks","last_synced_at":"2025-10-07T21:01:28.726Z","repository":{"id":60772186,"uuid":"218104674","full_name":"alanmcgovern/ReusableTasks","owner":"alanmcgovern","description":"An allocation free Task-like object for async methods","archived":false,"fork":false,"pushed_at":"2024-06-30T07:41:28.000Z","size":149,"stargazers_count":40,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-09-07T05:59:54.448Z","etag":null,"topics":["async","await","csharp","dotnet","performance","task","threading"],"latest_commit_sha":null,"homepage":"https://github.com/alanmcgovern/ReusableTasks/wiki","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alanmcgovern.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2019-10-28T17:19:25.000Z","updated_at":"2025-09-05T00:34:18.000Z","dependencies_parsed_at":"2024-06-12T11:21:50.324Z","dependency_job_id":"72a8a58d-0c8e-4bba-964b-4e90e54cf35c","html_url":"https://github.com/alanmcgovern/ReusableTasks","commit_stats":{"total_commits":60,"total_committers":3,"mean_commits":20.0,"dds":"0.30000000000000004","last_synced_commit":"37646b45a53a0a0dc2dbc8abfa0224e8d078aa36"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/alanmcgovern/ReusableTasks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanmcgovern%2FReusableTasks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanmcgovern%2FReusableTasks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanmcgovern%2FReusableTasks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanmcgovern%2FReusableTasks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alanmcgovern","download_url":"https://codeload.github.com/alanmcgovern/ReusableTasks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alanmcgovern%2FReusableTasks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275032780,"owners_count":25393760,"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","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["async","await","csharp","dotnet","performance","task","threading"],"created_at":"2024-10-13T09:16:59.333Z","updated_at":"2025-10-07T21:01:28.622Z","avatar_url":"https://github.com/alanmcgovern.png","language":"C#","readme":"# ReusableTask\n\n[![NuGet version](https://badge.fury.io/nu/reusabletasks.svg)](https://badge.fury.io/nu/reusabletasks)\n[![Build status](https://dev.azure.com/alanmcgovern0144/ReusableTasks/_apis/build/status/ReusableTasks-CI)](https://dev.azure.com/alanmcgovern0144/ReusableTasks/_build/latest?definitionId=3)\n\nA .NET Standard 2.0 compatible library which can be used to implement zero allocation async/await. This is conceptually similar to `ValueTask\u003cT\u003e`, except it's compatible with .NET 2.0 and has zero ongoing allocations once the internal cache initializes.\n\nSample usage:\n```\npublic async ReusableTask InitializeAsync ()\n{\n    if (!Initialized) {\n        await LongInitializationAsync ();\n        Initialized = true;\n    }\n}\n\nasync ReusableTask LongInitializationAsync ()\n{\n    // Contact a database, load from a file, etc\n}\n\npublic async ReusableTask\u003cMyData\u003e CreateMyDataAsync ()\n{\n    if (!Initialized) {\n        mydata = await LongMyDataCreationAsync ();\n        Initialized = true;\n    }\n    return mydata;\n}\n\nasync ReusableTask\u003cMyData\u003e LongMyDataCreationAsync ()\n{\n    // Contact a database, load from a file, etc..\n    return new MyData (....);\n}\n```\nThe compiler generated async state machine for these methods is allocation-free, and results in no garbage collectable objects being created no matter how many times the methods are invoked.\n\nThe four things you cannot do with `ValueTask` you also cannot do with `ReusableTask`. The documentation can be read here in the remarks section, https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.valuetask-1?view=netcore-3.0#remarks.\n\nUnlike the documentation states for `ValueTask`, I would recommend that the default return value for any async method should be `ReusableTask` or `ReusableTask\u003cT\u003e`, unless benchmarking shows otherwise.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falanmcgovern%2Freusabletasks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falanmcgovern%2Freusabletasks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falanmcgovern%2Freusabletasks/lists"}