{"id":13786674,"url":"https://github.com/andy2046/tik","last_synced_at":"2025-04-13T00:14:55.294Z","repository":{"id":57548077,"uuid":"277077004","full_name":"andy2046/tik","owner":"andy2046","description":"hierarchical timing wheel","archived":false,"fork":false,"pushed_at":"2020-10-17T03:23:45.000Z","size":40,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T00:14:48.685Z","etag":null,"topics":["ticker","timer","timing-wheel"],"latest_commit_sha":null,"homepage":"","language":"Go","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/andy2046.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}},"created_at":"2020-07-04T09:13:49.000Z","updated_at":"2022-11-29T03:42:44.000Z","dependencies_parsed_at":"2022-09-26T18:41:08.419Z","dependency_job_id":null,"html_url":"https://github.com/andy2046/tik","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Ftik","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Ftik/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Ftik/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Ftik/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andy2046","download_url":"https://codeload.github.com/andy2046/tik/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647274,"owners_count":21139086,"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":["ticker","timer","timing-wheel"],"created_at":"2024-08-03T19:01:27.856Z","updated_at":"2025-04-13T00:14:55.270Z","avatar_url":"https://github.com/andy2046.png","language":"Go","readme":"# tik\n\n[![Documentation](https://godoc.org/github.com/andy2046/tik?status.svg)](http://godoc.org/github.com/andy2046/tik)\n[![GitHub issues](https://img.shields.io/github/issues/andy2046/tik.svg)](https://github.com/andy2046/tik/issues)\n[![license](https://img.shields.io/github/license/andy2046/tik.svg)](https://github.com/andy2046/tik/LICENSE)\n[![Release](https://img.shields.io/github/release/andy2046/tik.svg?label=Release)](https://github.com/andy2046/tik/releases)\n\n----\n\n## hierarchical timing wheel made easy\n\nsimplified version of [timeout](https://github.com/wahern/timeout) in Golang\n\nfor documentation, view the [API reference](./doc.md)\n\n\n## Install\n\n```\ngo get github.com/andy2046/tik\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/andy2046/tik\"\n)\n\nfunc main() {\n\tvar l sync.RWMutex\n\t// init a new instance\n\ttk := tik.New()\n\ti := 0\n\tcb := func() {\n\t\tl.Lock()\n\t\ti++\n\t\tl.Unlock()\n\t}\n\t// schedule to run cb in 500ms\n\tto := tk.Schedule(500, cb)\n\n\tif !to.Pending() {\n\t\tpanic(\"it should be pending\")\n\t}\n\n\tif to.Expired() {\n\t\tpanic(\"it should NOT be expired\")\n\t}\n\n\tfor {\n\t\ttime.Sleep(100 * time.Millisecond)\n\n\t\tif tk.AnyPending() {\n\t\t\tcontinue\n\t\t}\n\n\t\tif tk.AnyExpired() {\n\t\t\tcontinue\n\t\t}\n\n\t\tbreak\n\t}\n\n\tl.RLock()\n\tdefer l.RUnlock()\n\n\tif i != 1 {\n\t\tpanic(\"fail to callback\", i)\n\t}\n}\n```\n","funding_links":[],"categories":["工具库","Utilities","公用事业公司","工具库`可以提升效率的通用代码库和工具`","Utility"],"sub_categories":["查询语","Utility/Miscellaneous","Fail injection","HTTP Clients","实用程序/Miscellaneous"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy2046%2Ftik","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandy2046%2Ftik","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy2046%2Ftik/lists"}