{"id":17062127,"url":"https://github.com/recp/tm","last_synced_at":"2025-10-07T01:49:42.609Z","repository":{"id":72428447,"uuid":"134251262","full_name":"recp/tm","owner":"recp","description":"timers and timeline","archived":false,"fork":false,"pushed_at":"2023-12-31T19:31:41.000Z","size":59,"stargazers_count":42,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-18T13:51:17.013Z","etag":null,"topics":["c-timer","clock","counter","time","timeline","timer","timer-clock","timer-functions"],"latest_commit_sha":null,"homepage":null,"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/recp.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}},"created_at":"2018-05-21T09:59:53.000Z","updated_at":"2024-11-08T01:06:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"decd0740-940c-40c7-b269-3d4d11da510c","html_url":"https://github.com/recp/tm","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/recp%2Ftm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2Ftm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2Ftm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/recp%2Ftm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/recp","download_url":"https://codeload.github.com/recp/tm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244995181,"owners_count":20544300,"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":["c-timer","clock","counter","time","timeline","timer","timer-clock","timer-functions"],"created_at":"2024-10-14T10:49:16.325Z","updated_at":"2025-10-07T01:49:37.584Z","avatar_url":"https://github.com/recp.png","language":"C","funding_links":[],"categories":["Utilities","公用事业"],"sub_categories":["YAML"],"readme":"# ⏱ Timer and Timeline Utils for `C`\n[![C/C++ CI](https://github.com/recp/tm/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/recp/tm/actions/workflows/c-cpp.yml)\n[![MSBuild](https://github.com/recp/tm/actions/workflows/msbuild.yml/badge.svg)](https://github.com/recp/tm/actions/workflows/msbuild.yml)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ba230efea5f94149822a48e12584942f)](https://www.codacy.com/app/recp/tm?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=recp/tm\u0026amp;utm_campaign=Badge_Grade)\n\nThis library provides an easy way to set timers and timeouts. \nAs initial version all timers run in single runloop at seperate thread. \nCurrently only one thread is used for all timers, because there is only one runloop. In the future multiple runloop may be allowed. \n\n#### Documentation\n\nCurrently all docs can be found in headers but in the future complete docs will be published. \n\n#### Javascript and Swift/Objective-C like API\n\n`setTimeout` in javascript is very useful and it is now in `C`:\n\n```C\ntm_settimeout(callback, arg, delay);\n```\n\n## TODOs:\n\n- [ ] Improve loopkup, make timers ordered. This may reduce some lookup operations runloop \n- [ ] Tests\n- [ ] More time and timeline utils\n- [ ] More platform support\n\n## Build\n\n### Unix (Autotools)\n\n```bash\n$ sh autogen.sh\n$ ./configure\n$ make\n$ [sudo] make install\n```\n\nyou can grap library in .libs folder after build finished\n\n### Windows (MSBuild)\nWindows related build files, project files are located in `win` folder,\nmake sure you are inside `tm/win` folder.\nCode Analysis are enabled, it may take awhile to build\n\n```Powershell\n$ cd win\n$ .\\build.bat\n```\n\n#### Example usage\n\n```C\n#include \u003ctm/tm.h\u003e\n\n/* callback */\nvoid\nmytimer(tm_timer *timer) {\n  printf(\"my timer\\n\");\n}\n\nvoid\ndelayed_func(void *arg) {\n  printf(\"settimeout: %s\\n\", (const char *)arg);\n}\n\nint \nmain(int argc, const char * argv[]) {\n  tm_timer   *timer1, *timer2, *timer3;\n  tm_interval start, end, elapsed;\n \n  /* option 1: alloc timer and start */\n  timer1 = tm_alloc(mytimer, 1.5); /* 1.5 seconds */\n  tm_start(timer1);\n  \n  /* option 2: alloc timer and start with delay */\n  timer2 = tm_alloc(mytimer, 1.5); /* 1.5 seconds */\n  tm_start_at(timer2, 0.05);       /* start after 0.05 secons */\n  \n  /* option 3: alloc timer and start with delay */\n  timer3 = tm_schedule(mytimer, 1.5, 0.05); /* same as tm_alloc + tm_start_at */\n  \n  /* option 4: javascript-like setTimeout */\n  tm_settimeout(delayed_func, \"Hello World!\", 0.00001);\n  \n  /*\n  \n  if we call free here timers will be stopped \n  \n  tm_free(timer1);\n  tm_free(timer2);\n  tm_free(timer3);\n\n  */\n  \n  /* measure elapsed time */\n  start = tm_time();\n  \n  /* do stuff */\n  \n  end = tm_time();\n  \n  elapsed = end - start;\n  \n  /* wait timers to finish; otherwise main thread will cause timer thread to be exited */\n  tm_wait();\n\n  return 0;\n}\n\n```\n\n## License\nMIT. check the LICENSE file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecp%2Ftm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frecp%2Ftm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frecp%2Ftm/lists"}