{"id":19036170,"url":"https://github.com/tx7do/linuxservertimer","last_synced_at":"2026-05-16T18:37:04.955Z","repository":{"id":112433649,"uuid":"429041264","full_name":"tx7do/LinuxServerTimer","owner":"tx7do","description":"linux game server timer","archived":false,"fork":false,"pushed_at":"2022-06-18T14:49:49.000Z","size":55,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-02T05:32:18.560Z","etag":null,"topics":["asio","game-engine","libevent","libuv","linux","timer","timerfd"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tx7do.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-11-17T12:42:15.000Z","updated_at":"2023-07-18T14:08:36.000Z","dependencies_parsed_at":"2023-05-15T02:45:19.746Z","dependency_job_id":null,"html_url":"https://github.com/tx7do/LinuxServerTimer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tx7do%2FLinuxServerTimer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tx7do%2FLinuxServerTimer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tx7do%2FLinuxServerTimer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tx7do%2FLinuxServerTimer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tx7do","download_url":"https://codeload.github.com/tx7do/LinuxServerTimer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240093142,"owners_count":19746774,"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":["asio","game-engine","libevent","libuv","linux","timer","timerfd"],"created_at":"2024-11-08T21:53:39.453Z","updated_at":"2026-05-16T18:36:59.929Z","avatar_url":"https://github.com/tx7do.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LinuxServerTimer\r\n\r\n本项目主要是为了实验一下使用WSL开发Linux程序。\r\n\r\n一开始用的是VS2022，但是用的感觉不是特别好，调试起来不太稳定，因为没有装VA，所以编写代码起来也很难受。\r\n\r\n后来转投JetBrian的CLion，编写代码比较舒服，支持Clang-Tidy，代码提示也比较精准。调试起来也很舒服，基本上没有出现什么问题。而且，在使用过程中，我发现它对Doxygen的支持也非常的好。\r\n\r\nVS呢，我也用了十多年了，以前用VS+VA，用起来感觉还是很愉快的。但是在JetBrain全家桶面前，我发现它差的有点远。\r\n\r\n本项目封装了5种实现方式：\r\n\r\n1. 使用sleep实现的低精度低性能定时器；\r\n2. 使用timerfd和epoll实现的高精度高性能定时器；  \r\n3. 使用libevent2实现的高精度高性能定时器；\r\n4. 使用boost::asio实现的高精度高性能定时器。\r\n5. 使用libuv实现的高精度高性能定时器。\r\n\r\n## 安装依赖库\r\n\r\n```bash\r\n# 安装libevent2\r\nsudo apt-get install libevent-dev\r\n\r\n# 安装boost\r\nsudo apt-get install libboost-all-dev\r\n# 安装独立版asio\r\nsudo apt-get install -y libasio-dev\r\n\r\n# 安装libuv\r\nsudo apt-get install libuv1-dev\r\n```\r\n\r\n## 使用方法\r\n\r\n```c++\r\n// 创建\r\nauto pITimer = CreateServerTimer(ServerTimerType_Epollfd);\r\n// 注册监听器\r\npITimer-\u003eRegisterListener(this);\r\n// 下一个无限循环的定时器\r\npITimer-\u003eSetTimer(88, 1000);\r\n// 下一个超时一次的定时器\r\npITimer-\u003eSetTimer(99, 1000, false);\r\n// 杀掉一个定时器\r\npITimer-\u003eKillTimer(88);\r\n// 杀掉所有的定时器\r\npITimer-\u003eKillAllTimer();\r\n// 销毁定时器\r\nDestroyServerTimer(pITimer);\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftx7do%2Flinuxservertimer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftx7do%2Flinuxservertimer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftx7do%2Flinuxservertimer/lists"}