{"id":13692568,"url":"https://github.com/99x/timercpp","last_synced_at":"2025-04-09T11:09:53.296Z","repository":{"id":44846351,"uuid":"154458039","full_name":"99x/timercpp","owner":"99x","description":"Javascript like setTimeout and setInterval for c++ developers","archived":false,"fork":false,"pushed_at":"2022-10-08T23:48:37.000Z","size":12,"stargazers_count":258,"open_issues_count":9,"forks_count":76,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-02T10:12:09.065Z","etag":null,"topics":["cpp","cpp14","header-only","setinterval","settimeout"],"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/99x.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":"2018-10-24T07:32:00.000Z","updated_at":"2025-03-22T11:02:07.000Z","dependencies_parsed_at":"2023-01-19T16:17:17.224Z","dependency_job_id":null,"html_url":"https://github.com/99x/timercpp","commit_stats":null,"previous_names":["shalithasuranga/timercpp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/99x%2Ftimercpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/99x%2Ftimercpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/99x%2Ftimercpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/99x%2Ftimercpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/99x","download_url":"https://codeload.github.com/99x/timercpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027408,"owners_count":21035594,"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":["cpp","cpp14","header-only","setinterval","settimeout"],"created_at":"2024-08-02T17:00:59.534Z","updated_at":"2025-04-09T11:09:53.262Z","avatar_url":"https://github.com/99x.png","language":"C++","readme":"# timercpp\nJavascript like timer for c++ developers\n\nThis header only library has js equivalent `setTimeout()` and `setInterval()` for c++.\n\n**DISCLAIMER - This implementation uses threads not a queue**\n\n## `setTimeout(auto function, int delay)`\n\n```c++\nTimer t = Timer();\nt.setTimeout([\u0026]() {\n    cout \u003c\u003c \"Hey.. After 1s.\" \u003c\u003c endl;\n}, 1000); \n```\n\n## `setInterval(auto function, int interval)`\n\n```c++\nTimer t = Timer();\nt.setInterval([\u0026]() {\n    cout \u003c\u003c \"Hey.. After each 1s...\" \u003c\u003c endl;\n}, 1000); \n```\n\n## Sample Program\n\n```c++\n#include \u003ciostream\u003e\n#include \"timercpp.h\"\n\nusing namespace std;\n\nint main() {\n    Timer t = Timer();\n\n    t.setInterval([\u0026]() {\n        cout \u003c\u003c \"Hey.. After each 1s...\" \u003c\u003c endl;\n    }, 1000); \n\n    t.setTimeout([\u0026]() {\n        cout \u003c\u003c \"Hey.. After 5.2s. But I will stop the timer!\" \u003c\u003c endl;\n        t.stop();\n    }, 5200); \n\n    \n\n    cout \u003c\u003c \"I am Timer\" \u003c\u003cendl;\n\n\n    while(true); // Keep main thread active\n}\n```\n\n**Output**\n\n```\nI am Timer\nHey.. After each 1s...\nHey.. After each 1s...\nHey.. After each 1s...\nHey.. After each 1s...\nHey.. After each 1s...\nHey.. After 5.2s. But I will stop the timer!\n```\n\n### How to compile sample program?\n\n```bash\ng++ sample.cpp -std=c++14 -pthread\n```\n\n### License\n\n[MIT](https://github.com/shalithasuranga/timercpp/edit/master/LICENSE)\n","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F99x%2Ftimercpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F99x%2Ftimercpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F99x%2Ftimercpp/lists"}