{"id":22206731,"url":"https://github.com/usercode/asynckeylock","last_synced_at":"2025-07-27T07:32:33.293Z","repository":{"id":65677358,"uuid":"514260445","full_name":"usercode/AsyncKeyLock","owner":"usercode","description":"Async Key-based Reader Writer Lock with Cancellation Support","archived":false,"fork":false,"pushed_at":"2024-03-26T15:48:27.000Z","size":56,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-29T05:56:55.650Z","etag":null,"topics":["csharp","dotnet","locking"],"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/usercode.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}},"created_at":"2022-07-15T12:24:42.000Z","updated_at":"2024-09-20T08:03:25.000Z","dependencies_parsed_at":"2023-02-18T19:01:24.445Z","dependency_job_id":"5a562a25-3b22-4088-9260-ca8f593d8765","html_url":"https://github.com/usercode/AsyncKeyLock","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":"0.023809523809523836","last_synced_commit":"57df81c1e9d9e1d25d3dd72dc7dd5a66b3088efc"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usercode%2FAsyncKeyLock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usercode%2FAsyncKeyLock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usercode%2FAsyncKeyLock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usercode%2FAsyncKeyLock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/usercode","download_url":"https://codeload.github.com/usercode/AsyncKeyLock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227777711,"owners_count":17818455,"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":["csharp","dotnet","locking"],"created_at":"2024-12-02T18:17:43.586Z","updated_at":"2024-12-02T18:17:44.227Z","avatar_url":"https://github.com/usercode.png","language":"C#","readme":"# Async Key-based Reader Writer Lock with Cancellation Support\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)\n[![NuGet](https://img.shields.io/nuget/v/AsyncKeyLock.svg?style=flat-square)](https://www.nuget.org/packages/AsyncKeyLock)\n\n- Can create reader and writer locks (with key).\n- A reader lock allows concurrent access for read-only operations.\n- A writer lock allows exclusive access for operations.\n- It based internally on TaskCompletionSources which will be queued.\n\n## How to use it\n\n```csharp\n//async lock\nAsyncLock asyncLock = new AsyncLock();\n\n//async lock with key\nAsyncLock\u003cstring\u003e asyncLock = new AsyncLock\u003cstring\u003e();\n\n//acquire reader lock\nvar d1 = await asyncLock.ReaderLockAsync(\"123\");\n\n//release reader lock\nd1.Dispose();\n\n//set timeout\nusing CancellationTokenSource cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));\n\n//acquire writer lock\nusing var d2 = await asyncLock.WriterLockAsync(\"123\", cts.Token);\n\n//use writer lock scope to interrupt long running reader lock\nusing (ReaderReleaser r1 = await asyncLock.ReaderLockAsync())\n{\n   //use reader lock\n\n   if (..)\n   {\n      r1.UseWriterLockAsync(async () =\u003e { /*use writer lock here*/ });\n   }\n\n   //continue with reader lock\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusercode%2Fasynckeylock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusercode%2Fasynckeylock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusercode%2Fasynckeylock/lists"}