{"id":19334056,"url":"https://github.com/stefanolusardi/task_scheduler","last_synced_at":"2025-04-22T17:03:12.110Z","repository":{"id":54738456,"uuid":"295651786","full_name":"StefanoLusardi/task_scheduler","owner":"StefanoLusardi","description":"Small \u0026 Simple Task Scheduler for C++17","archived":false,"fork":false,"pushed_at":"2023-03-15T23:39:30.000Z","size":344,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T17:01:26.358Z","etag":null,"topics":["cmake","continuous-integration","cpp17","cross-platform","examples","header-only","no-dependencies","task-pool","task-scheduler","unit-test"],"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/StefanoLusardi.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-09-15T07:40:41.000Z","updated_at":"2025-01-21T14:19:19.000Z","dependencies_parsed_at":"2025-04-22T17:02:01.360Z","dependency_job_id":null,"html_url":"https://github.com/StefanoLusardi/task_scheduler","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/StefanoLusardi%2Ftask_scheduler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoLusardi%2Ftask_scheduler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoLusardi%2Ftask_scheduler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanoLusardi%2Ftask_scheduler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StefanoLusardi","download_url":"https://codeload.github.com/StefanoLusardi/task_scheduler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250285542,"owners_count":21405296,"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":["cmake","continuous-integration","cpp17","cross-platform","examples","header-only","no-dependencies","task-pool","task-scheduler","unit-test"],"created_at":"2024-11-10T02:56:05.570Z","updated_at":"2025-04-22T17:03:11.993Z","avatar_url":"https://github.com/StefanoLusardi.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ssTs: Small \u0026amp; Simple Task Scheduler for C++17\n\n**ssTs** is a time-based *Task Scheduler*, written in modern C++.  \nHeader only, with [no external dependencies](#tests).\n\n[Try **ssTs** out on Wandbox!](https://wandbox.org/permlink/yTJVogjpcsZzzyNq)\n\n![ssTs](/docs/logo/ssts_logo.png) \n\n\n[![License](https://img.shields.io/badge/License-MIT-blue)](https://github.com/StefanoLusardi/task_scheduler/blob/master/LICENSE) \n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/StefanoLusardi/task_scheduler/issues) \n[![Try online](https://img.shields.io/badge/try-online-orange.svg)](https://wandbox.org/permlink/yTJVogjpcsZzzyNq) \n\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/StefanoLusardi/task_scheduler.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/StefanoLusardi/task_scheduler/alerts/) \n[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/StefanoLusardi/task_scheduler.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/StefanoLusardi/task_scheduler/context:cpp) \n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/145999f67a5f4d25acec749b0896e47d)](https://www.codacy.com/manual/StefanoLusardi/task_scheduler/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=StefanoLusardi/task_scheduler\u0026amp;utm_campaign=Badge_Grade) \n\n[![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master) \n![Azure DevOps tests](https://img.shields.io/azure-devops/tests/stefanolusardi/ssts/16) \n[![codecov](https://codecov.io/gh/StefanoLusardi/task_scheduler/branch/master/graph/badge.svg)](https://codecov.io/gh/StefanoLusardi/task_scheduler) \n[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/82f58a941701453eba4f7d610660cf55)](https://www.codacy.com/gh/StefanoLusardi/task_scheduler/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=StefanoLusardi/task_scheduler\u0026amp;utm_campaign=Badge_Coverage) \n\n[![Documentation Status](https://readthedocs.org/projects/task-scheduler/badge/?version=latest)](https://task-scheduler.readthedocs.io/en/latest/?badge=latest) \n[![Documentation](https://codedocs.xyz/StefanoLusardi/task_scheduler.svg)](https://codedocs.xyz/StefanoLusardi/task_scheduler/) \n\n![GitHub top language](https://img.shields.io/github/languages/top/stefanolusardi/task_scheduler) \n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/stefanolusardi/task_scheduler) \n![GitHub repo size](https://img.shields.io/github/repo-size/stefanolusardi/task_scheduler) \n![GitHub Issues](https://img.shields.io/github/issues/stefanolusardi/task_scheduler) \n\n![GitHub last commit](https://img.shields.io/github/last-commit/stefanolusardi/task_scheduler) \n![GitHub release (latest by date)](https://img.shields.io/github/v/release/stefanolusardi/task_scheduler) \n![GitHub Release Date](https://img.shields.io/github/release-date/stefanolusardi/task_scheduler) \n\n- [Integration](#integration)\n  - [Header only](#header-only)\n  - [CMake](#cmake)\n- [Supported OS and Compilers](#supported-os-and-compilers)\n  - [Development platforms](#development-platforms)\n  - [CI platforms](#ci-platforms)\n- [Basic Usage](#basic-usage)\n- [Documentation](#documentation)\n- [Examples](#examples)\n- [Tests](#tests)\n\n## Integration\n\n### Header only\nCopy the [include](/include) folder, that contains the 3 header files [task.hpp](/include/ssts/task.hpp), [task_pool.hpp](/include/ssts/task_pool.hpp) and [task_scheduler.hpp](/include/ssts/task_scheduler.hpp) within your project sources or set your include path to it and just build your code.  \n**ssTs** requires a *C++17* compiler.\n\n### CMake\nIt is possible to *install* the library using:\n```console\n$ git clone https://github.com/stefanolusardi/task_scheduler.git\n$ cd ssts \u0026\u0026 mkdir build \u0026\u0026 cd build\n$ cmake -G\u003cGENERATOR\u003e -DCMAKE_BUILD_TYPE=\u003cDebug|Release\u003e -DSSTS_INSTALL_LIBRARY=True -DCMAKE_INSTALL_PREFIX=\u003c/install/folder/path\u003e ..\n$ cmake --build . --config \u003cDebug|Release\u003e --target install \n```\n\n## Supported OS and Compilers\n\n### Development platforms\n*  Windows 10 - Visual Studio 2019\n*  Windows 10 - Clang 10.0\n*  Windows 10 - Clang 9.0\n*  Ubuntu 20.04 - GCC 9.3\n*  Ubuntu 20.04 - Clang 9.0\n*  Ubuntu 20.04 - Clang 10.0\n\n### CI platforms\n\n#### Linux\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu2004_GCC9)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 20.04 - GCC 9.3\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu1804_GCC9)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 18.04 - GCC 9.3\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu1804_GCC7)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 18.04 - GCC 7.5\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu1804_GCC8)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 18.04 - GCC 8.4\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu2004_GCC7)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 20.04 - GCC 7.5\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu2004_GCC8)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 20.04 - GCC 8.4\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu1804_Clang8)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 18.04 - Clang 8.0\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu1804_Clang9)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 18.04 - Clang 9.0\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu2004_Clang8)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 20.04 - Clang 8.0\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu2004_Clang9)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 20.04 - Clang 9.0\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Ubuntu2004_Clang10)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nUbuntu 20.04 - Clang 10.0\n\n#### Windows\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Windows2019_VisualStudio2019)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nWindows Server 2019 - Visual Studio 2019\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Windows2016_VisualStudio2017)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nWindows Server 2016 - Visual Studio 2017\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Windows2019_Clang10)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nWindows Server 2019 - Clang 10.0\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=Windows2016_Clang10)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nWindows Server 2016 - Clang 10.0\n\n#### MacOS\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=MacOSMojave1014_Clang10)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nMacOS X Mojave 10.14 - Clang 10.0\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=MacOSMojave1014_GCC8)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nMacOS X Mojave 10.14 - GCC 8.4\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=MacOSMojave1014_GCC9)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nMacOS X Mojave 10.14 - GCC 9.3\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=MacOSCatalina1015_Clang10)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nMacOS X Catalina 10.15 - Clang 10.0\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=MacOSCatalina1015_GCC8)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nMacOS X Catalina 10.15 - GCC 8.4\n\n*  [![Build Status](https://stefanolusardi.visualstudio.com/ssts/_apis/build/status/ssts?branchName=master\u0026jobName=MacOSCatalina1015_GCC9)](https://stefanolusardi.visualstudio.com/ssts/_build/latest?definitionId=16\u0026branchName=master)\nMacOS X Catalina 10.15 - GCC 9.3\n\n## Basic Usage\n\n*  Running a task is as simple as:\n```cpp\n// Create a Task Scheduler instance\nts::task_scheduler s(2);\n\n// Start Task Scheduler\ns.start()\n\n// Spawn a one-shot task in 5 seconds\ns.in(5s, []{std::cout \u003c\u003c \"Hello!\" \u003c\u003c std::endl;});\n```\n\n*  To retrieve a task result you can do:\n```cpp\n// Launch a task with parameters and wait for its return value\nstd::future f = s.at(std::chrono::steady_clock::now() + 2s, \n[](auto x, auto y){ \n    std::cout \u003c\u003c \"Input parameters: \" \u003c\u003c x \u003c\u003c y \u003c\u003c std::endl;\n    return x+1; \n}, 42, \"fourty-two\");\n\nstd::cout \u003c\u003c \"Task result: \" \u003c\u003c f.get() \u003c\u003c std::endl; // prints 43\n```\n\n*  It's possible to start a task giving it a task id to be able to manipulate it later:\n```cpp\n// Check if a task is currently scheduled \n// (i.e. already inserted in the scheduler)\ns.is_scheduled(\"my_task_id\"); // false\n\n// Check if a task is currently enabled\n// (i.e. inserted and allowed to execute, by default any task is enabled)\ns.is_enabled(\"my_task_id\"); // false\n\n// Start a recursive task with a task id that is scheduled every second\ns.every(\"my_task_id\", 1s, [](auto p){std::cout \u003c\u003c \"Hello! \" \u003c\u003c p \u003c\u003c std::endl;}, \"some_task_parameter\");\ns.is_scheduled(\"my_task_id\"); // true\ns.is_enabled(\"my_task_id\"); // true\n\n// Disable \"my_task_id\"\ns.set_enabled(\"my_task_id\", false);\ns.is_scheduled(\"my_task_id\"); // true\ns.is_enabled(\"my_task_id\"); // false\n\n// Remove \"my_task_id\"\ns.remove_task(\"my_task_id\"s);\ns.is_scheduled(\"my_task_id\"); // false\ns.is_enabled(\"my_task_id\"); // false\n\n// Stop Task Scheduler (by default it's always properly stopped when it goes out of scope)\ns.stop();\n```\n\n*  Nested task creation and execution is also supported:\n```cpp\ns.every(\"parent_task_id\", 1s, \n    [\u0026s]{ \n        std::cout \u003c\u003c \"Parent Task!\" \u003c\u003c std::endl;\n        s.in(\"inner_task_id\", 100ms, []{ std::cout \u003c\u003c \"Child Task!\" \u003c\u003c std::endl; });\n    });\n```\n\n## Documentation\n*Documentation* sources are located in the [docs](/docs) folder.\nAn online version of the latest docs can be found [here](https://task-scheduler.readthedocs.io/en/latest/).  \nDocs are automatically generated from source code at every commit using *Doxygen*, *Breathe* and *Sphinx* and are hosted on *Read The Docs*.\nIt is possible to build the docs from CMake (*Doxygen*, *Breathe* and *Sphinx* are required) using:\n```console\n$ git clone https://github.com/stefanolusardi/task_scheduler.git\n$ cd ssts \u0026\u0026 mkdir build \u0026\u0026 cd build\n$ cmake -G\u003cGENERATOR\u003e -DSSTS_BUILD_DOCS=True ..\n$ cmake --build . \n```\n\n## Examples\n*Examples* are located within the [examples](/examples) folder.  \nIt is possible to build and install the *examples* using:\n```console\n$ git clone https://github.com/stefanolusardi/task_scheduler.git\n$ cd ssts \u0026\u0026 mkdir build \u0026\u0026 cd build\n$ cmake -G\u003cGENERATOR\u003e -DCMAKE_BUILD_TYPE=\u003cDebug|Release\u003e -DSSTS_BUILD_EXAMPLES=True -DSSTS_INSTALL_LIBRARY=True -DSSTS_INSTALL_EXAMPLES=True ..\n$ cmake --build . --config \u003cDebug|Release\u003e\n```\n\n## Tests\n*Tests* are located within the [tests](/tests) folder.  \n[GoogleTest](https://github.com/google/googletest) is the only 3rd party library used and it is required only to build the tests target.\nIt is integrated using [DownloadGoogleTest.cmake](/cmake/DownloadGoogleTest.cmake) script. \nIt is possible to build the *tests* using:\n```console\n$ git clone https://github.com/stefanolusardi/task_scheduler.git\n$ cd ssts \u0026\u0026 mkdir build \u0026\u0026 cd build\n$ cmake -G\u003cGENERATOR\u003e -DCMAKE_BUILD_TYPE=\u003cDebug|Release\u003e -DSSTS_BUILD_TESTS=True ..\n$ cmake --build . --config \u003cDebug|Release\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanolusardi%2Ftask_scheduler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanolusardi%2Ftask_scheduler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanolusardi%2Ftask_scheduler/lists"}