{"id":18048298,"url":"https://github.com/relintai/thread_pool","last_synced_at":"2025-09-18T14:06:20.033Z","repository":{"id":107319255,"uuid":"266501779","full_name":"Relintai/thread_pool","owner":"Relintai","description":"A c++ Godot engine module which makes it easy to run methods in threads.","archived":false,"fork":false,"pushed_at":"2023-01-09T20:15:58.000Z","size":43,"stargazers_count":9,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T09:58:18.215Z","etag":null,"topics":[],"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/Relintai.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":"2020-05-24T08:40:55.000Z","updated_at":"2023-12-05T22:13:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"23a3ad1e-2492-43c8-8fbc-013fe246f8d9","html_url":"https://github.com/Relintai/thread_pool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Relintai/thread_pool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relintai%2Fthread_pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relintai%2Fthread_pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relintai%2Fthread_pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relintai%2Fthread_pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Relintai","download_url":"https://codeload.github.com/Relintai/thread_pool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Relintai%2Fthread_pool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275780783,"owners_count":25527345,"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","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-30T20:12:20.741Z","updated_at":"2025-09-18T14:06:20.007Z","avatar_url":"https://github.com/Relintai.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Thread pool module\n\nA c++ Godot engine module, that will help you with threading.\n\nIt can also work if threads are not available (like on the javascript backend), in this case it runs jobs on the \nmain thread. Jobs themselves can also distribute their work onto multiple frames, and you can set how much time \nis allocated per frame.\n\nYou can access it's setting from the `Project-\u003eProject Settings...` menu, in the `ThreadPool` category.\n\n## Godot Version Support\n\nThis branch tries to follow godot's master branch (as much as I have time).\n\nFor different godot versions look at the other branches.\n\nStatus for this branch: Update for 4.0 is work in progress.\n\n# ThreadPoolJob\n\nContains a job that can run on different threads.\n\nA job is only considered finished, if you set the 'complete' property to 'true'. If multiple threads are available, \nthe system will not check for this though, because there is no need.\n\nIf you want to support envioronments that doesn't have threading, you can use:\n\n```\nbool should_do(const bool just_check = false);\nbool should_return();\n```\n\nFor example:\n\n```\nfunc _execute():\n    # On the first run this will return true, on subsequest runs it will return false\n    if should_do():\n        thing1()\n\n    # if you ran out the allocated timeframe in a frame, this will return true\n    if should_return():\n        return\n\n    if should_do():\n        thing2()\n\n    if should_return():\n        return\n\n    thing3()\n\n    complete = true\n\n```\n\n`should_do`'s optional parameter will let you just query the system, whether you finished a step, without\nincrementing internal couters. This is useful for example to distribute algorithms onto multiple frames.\n\nFor example:\n\n```\nfunc _execute():\n    if should_do(true):\n        while current \u003c= elements.size():\n            #do heavy calculations\n\n            current += 1\n\n            if should_return():\n                return\n\n        #The heavy calculation finished, increment counters\n        should_do()\n    \n    if should_return():\n        return\n\n    if should_do():\n        thing2()\n\n    if should_return():\n        return\n\n    thing3()\n\n    complete = true\n\n```\n\nThis class will need litle tweaks, hopefully I can get to is soon.\n\n# ThreadPoolExecuteJob\n\nThis will let you run a method uin an another thread, without creating your own jobs.\n\nUse it through the ThreadPool Singleton. Like:\n\n```\nThreadPool.create_execute_job(self, \"method\", arg1, arg2, ...)\n\n#or\nThreadPool.create_execute_job_simple(self, \"method\")\n```\n\nThis class will need litle tweaks, hopefully I can get to is soon.\n\n# ThreadPool singleton\n\nThe ThreadPool singleton handles jobs.\n\nIf you have a job, submit it using `add_job`:\n\n```\nMyJob job = MyJob.new()\nThreadPool.add_job(job)\n```\n\nIt's api is still a bit messy, it will be cleaned up (hopefully very soon).\n\n# Building\n\n1. Get the source code for the engine.\n\nIf you want Godot 3.2:\n```git clone -b 3.2 https://github.com/godotengine/godot.git godot```\n\nIf you want Godot 4.0:\n```git clone https://github.com/godotengine/godot.git godot```\n\n[last tested commit](https://github.com/godotengine/godot/commit/b7e10141197fdd9b0dbc4cfa7890329510d36540)\n\n2. Go into Godot's modules directory.\n\n```\ncd ./godot/modules/\n```\n\n3. Clone this repository\n\n```\ngit clone https://github.com/Relintai/thread_pool thread_pool\n```\n\n4. Build Godot. [Tutorial](https://docs.godotengine.org/en/latest/development/compiling/index.html)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelintai%2Fthread_pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frelintai%2Fthread_pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frelintai%2Fthread_pool/lists"}