{"id":22899733,"url":"https://github.com/wolfulus/cpptimer","last_synced_at":"2025-05-08T01:10:13.463Z","repository":{"id":84705396,"uuid":"37685823","full_name":"WoLfulus/cpptimer","owner":"WoLfulus","description":"simple c++11 timer","archived":false,"fork":false,"pushed_at":"2015-06-23T03:23:35.000Z","size":140,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T01:10:00.168Z","etag":null,"topics":["cpp","cpp11","header-only","interval","timeout","timer","timers"],"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/WoLfulus.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":"2015-06-18T21:24:07.000Z","updated_at":"2023-04-26T02:07:20.000Z","dependencies_parsed_at":"2023-02-26T01:25:40.282Z","dependency_job_id":null,"html_url":"https://github.com/WoLfulus/cpptimer","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/WoLfulus%2Fcpptimer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WoLfulus%2Fcpptimer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WoLfulus%2Fcpptimer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WoLfulus%2Fcpptimer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WoLfulus","download_url":"https://codeload.github.com/WoLfulus/cpptimer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978768,"owners_count":21834916,"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","cpp11","header-only","interval","timeout","timer","timers"],"created_at":"2024-12-14T01:16:17.519Z","updated_at":"2025-05-08T01:10:13.441Z","avatar_url":"https://github.com/WoLfulus.png","language":"C++","readme":"cpptimer\n============\n\nSimple C++11 timers (interval, timeout, repeat).\n\nIn-process timers for periodic jobs that uses builder pattern for configuration. cpptimer lets you run any thing convertible to a **std::function\u003cvoid()\u003e** periodically at pre-determined intervals using a simple human-friendly syntax.\n\nFeatures\n--------\n\n- Simple fluent/builder API\n- Allows single or multi thread updates\n- Thread-safe\n- Single-file header only\n- No dependencies \n\nRequirements\n------------\n\n**cpptimer** requires a C++11 compiler only with `\u003cctime\u003e` and `\u003cchrono\u003e` libraries.\n\nUsage\n-----\n\nCreating the timer manager.\n\n```c++\n\n    timer::manager mgr;\n```\n\nRegistering tasks\n\n```cpp\n\n\tmgr.interval([]() {\n\t\tcout \u003c\u003c \"Happens every 5 second\" \u003c\u003c endl;\n\t}, std::chrono::seconds(5));\n\n\tmgr.timeout([]() {\n\t\tcout \u003c\u003c \"Happens once after 10 seconds\" \u003c\u003c endl;\n\t}, std::chrono::seconds(10));\n\n\tmgr.repeat([]() {\n\t\tcout \u003c\u003c \"Happens 5 times every 3 seconds\" \u003c\u003c endl;\n\t}, std::chrono::seconds(3), 5);\n\n```\n\nCanceling a task\n\n```cpp\n    \n\tauto id = mgr.timeout(func, std::chrono::seconds(60));\n\t...\n\tmgr.cancel(id);\n\n```\n\nUpdating the timers on your own thread\n\n```cpp\n\n    while (true)\n\t{\n\t\tmgr.update();\n\t\tboost::this_thread::sleep_for(\n\t\t\tboost::chrono::milliseconds(200));\n\t}\n\n```\n\nLeaving updates to the timer \n\n*Note that this will create an additional thread and all updates will run under manager's thread*\n\n\n```cpp\n\n\t// default interval (250ms)\n\tmgr.start();\n\n\t// or with a custom interval for each update\n\tmgr.start(std::chrono::milliseconds(200)); \n\t\n```\n\nDistributed under the MIT license. See ``LICENSE`` for more information.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolfulus%2Fcpptimer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwolfulus%2Fcpptimer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolfulus%2Fcpptimer/lists"}