{"id":16683060,"url":"https://github.com/hlts2/gpin","last_synced_at":"2025-08-10T10:23:00.314Z","repository":{"id":144255877,"uuid":"439041745","full_name":"hlts2/gpin","owner":"hlts2","description":"A spinlock implementation for Go. ","archived":false,"fork":false,"pushed_at":"2021-12-20T01:35:59.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-08T11:48:07.910Z","etag":null,"topics":["faster","go","go-library","golang","golang-library","goroutine-safe","lock","simple"],"latest_commit_sha":null,"homepage":"","language":"Go","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/hlts2.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}},"created_at":"2021-12-16T15:38:54.000Z","updated_at":"2021-12-20T12:53:37.000Z","dependencies_parsed_at":"2023-06-26T00:49:53.344Z","dependency_job_id":null,"html_url":"https://github.com/hlts2/gpin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hlts2/gpin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlts2%2Fgpin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlts2%2Fgpin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlts2%2Fgpin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlts2%2Fgpin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hlts2","download_url":"https://codeload.github.com/hlts2/gpin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hlts2%2Fgpin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268310786,"owners_count":24230183,"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-08-01T02:00:08.611Z","response_time":67,"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":["faster","go","go-library","golang","golang-library","goroutine-safe","lock","simple"],"created_at":"2024-10-12T14:10:12.470Z","updated_at":"2025-08-01T23:05:54.393Z","avatar_url":"https://github.com/hlts2.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gpin\nA [spinlock](https://en.wikipedia.org/wiki/Spinlock) implementation for Go. \n\n## Requirement\n\nGo 1.17\n\n\n## Installation\n```shell\ngo get github.com/hlts2/gpin\n```\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/hlts2/gpin\"\n)\n\ntype Counter struct {\n\tl gpin.Spinlock\n\tv map[string]int\n}\n\nfunc (c *Counter) Increment(key string) {\n\tc.l.Lock()\n\tc.v[key]++\n\tc.l.Unlock()\n}\n\nfunc (c *Counter) Get(key string) int {\n\tc.l.Lock()\n\tdefer c.l.Unlock()\n\treturn c.v[key]\n}\n\nfunc main() {\n\tc := Counter{\n\t\tv: make(map[string]int),\n\t}\n\tfor i := 0; i \u003c 100; i++ {\n\t\tgo c.Increment(\"example\")\n\t}\n\n\ttime.Sleep(time.Second)\n\tfmt.Println(c.Get(\"example\")) // 100\n}\n\n```\n\n## Benchmark\n\n```\ngoos: linux\ngoarch: amd64\npkg: github.com/hlts2/gpin\ncpu: 11th Gen Intel(R) Core(TM) i9-11900K @ 3.50GHz\nBenchmarkMutex\nBenchmarkMutex-16       \t10193804\t       135.3 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkSpinlock\nBenchmarkSpinlock-16    \t43065172\t        30.98 ns/op\t       0 B/op\t       0 allocs/op\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhlts2%2Fgpin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhlts2%2Fgpin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhlts2%2Fgpin/lists"}