{"id":16018570,"url":"https://github.com/nepitwin/threadwatcher","last_synced_at":"2025-04-05T03:24:01.680Z","repository":{"id":164521463,"uuid":"147971272","full_name":"Nepitwin/ThreadWatcher","owner":"Nepitwin","description":"Watcher service to monitor threads.","archived":false,"fork":false,"pushed_at":"2022-06-01T20:04:00.000Z","size":284,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-10T11:34:44.467Z","etag":null,"topics":["c-plus-plus","cmake","hunter","std-thread","stl"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nepitwin.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}},"created_at":"2018-09-08T21:29:25.000Z","updated_at":"2023-09-10T02:26:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc5d9a89-191a-4497-b1be-a0870380fb4a","html_url":"https://github.com/Nepitwin/ThreadWatcher","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/Nepitwin%2FThreadWatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nepitwin%2FThreadWatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nepitwin%2FThreadWatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nepitwin%2FThreadWatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nepitwin","download_url":"https://codeload.github.com/Nepitwin/ThreadWatcher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247282218,"owners_count":20913321,"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-plus-plus","cmake","hunter","std-thread","stl"],"created_at":"2024-10-08T17:00:23.902Z","updated_at":"2025-04-05T03:24:01.654Z","avatar_url":"https://github.com/Nepitwin.png","language":"C++","readme":"# Thread Watcher\n\nThread watcher is a C++ based implementation to monitor running threads by executions states. \n\n| Build         | Status        |\n| ------------- |:-------------:|\n| Windows       | [![Build status](https://ci.appveyor.com/api/projects/status/8lek5cqicj7ma49o?svg=true)](https://ci.appveyor.com/project/Nepitwin/threadwatcher) |\n| Linux         | [![Build Status](https://travis-ci.org/Nepitwin/ThreadWatcher.svg?branch=master)](https://travis-ci.org/Nepitwin/ThreadWatcher) |\n\n\n![Thread Watcher][watcher]\n\n## Process states\n\nEache processing thread starts by an Init state if only created but not started from thread watcher. If thread watcher is running all process will be automatic executed and has the running state. By stopping an process it trys to Stop this thread clean (finished) and if it's not work hard killed (killed). If both methods to kill not work an killed exception status will be set to process.\n\n![Process states][states]\n\n## Build\n\nThis project can be build with cmake for all platforms. All dependencies will be downloaded from hunter repository. Currently the source code part to kill processes hard is not platform independent and use the Windows API. \n\nBuild with ccmake\n```\nccmake . \n```\n\nBuild with cmake\n```\ncd build\ncmake ..\n```\n\n### Example\n\nThis example codes shows a simple usage from thread watcher.\n\nFirst of all code an process class which implements the IFunction interface.\n\n```\nclass CleanProcess : public ::IFunction\n{\n\npublic:\n\n    CleanProcess()\n    {\n        stopProcess = false;\n    }\n\n    virtual ~CleanProcess() {};\n\n    /**\n     * Overridden function.\n     */\n    void process() override\n    {\n        while (!stopProcess) \n        {\n             // Implement here your processing code\n        }\n    }\n\n    /**\n     * Overridden function.\n     */\n    void Stop() override\n    {\n        stopProcess = true;\n    }\n\nprivate:\n\n    /**\n     * @brief Atomic boolean to Stop process.\n     */\n    std::atomic\u003cbool\u003e stopProcess;\n};\n```\n\nUse this processing in an thread watcher to monitor his running states and Start watcher to Watch all added processes.\n\n```\nThreadWatcher watcher;\nstd::shared_ptr\u003cIFunction\u003e ptrProcess(new CleanProcess());\nstd::shared_ptr\u003cProcess\u003e processClean(new Process(ptrProcess));\nwatcher.AddProcess(\"PROCESS_A39\", processClean);\n// Added process will be in state init if watcher not started.\nwatcher.HasProcessStatus(\"PROCESS_A39\", Process::Status::INIT)\n\n// Important this call will block the execution by thread.join() method from watcher.\nwatcher.Watch();\n\n// If watcher is started process should be in state run.\nwatcher.HasProcessStatus(\"PROCESS_A39\", Process::Status::RUN)\n```\n\n## License\n\nCopyright 2017-2018 Andreas Sekulski\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n[states]: Process_States.png\n[watcher]: ThreadWatcher.png\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnepitwin%2Fthreadwatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnepitwin%2Fthreadwatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnepitwin%2Fthreadwatcher/lists"}