-
-
Notifications
You must be signed in to change notification settings - Fork 21k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update WorkerThreadPool doc to mention every task should be waited so that any allocated resources can be cleaned up. #84926
Update WorkerThreadPool doc to mention every task should be waited so that any allocated resources can be cleaned up. #84926
Conversation
This is certainly the easy way forward, but I wouldn't exactly call it a fix. The documentation for WorkerThreadPool explicitly states:
Having to track task ids and make sure to call wait_for_task_completion without blocking the main thread is not "simple". |
I wrote the docs without much knowledge on the subject matter, only some testing. I wouldn't take them for gospel, moreover, this seems like a technical limitation. And it's still simpler than multithreading with Thread. |
0e1c7a2
to
4d358f0
Compare
Seems this should also resolve #84899 (it's kinda a duplicate of #84888). While at it, it's probably a good idea to also add some notes to var id = WorkerThreadPool.add_task(some_task)
...
WorkerThreadPool.is_task_completed(id) # false/true
...
WorkerThreadPool.wait_for_task_completion(id)
WorkerThreadPool.is_task_completed(id) # false, and "Invalid Task ID" error godot/core/object/worker_thread_pool.cpp Lines 293 to 305 in d5217b6
godot/core/object/worker_thread_pool.cpp Lines 486 to 496 in d5217b6
|
at some point so that any allocated resources can be cleaned up.
4d358f0
to
492785b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A fire-and-forget API could be added in the future, provided tracking task ids is really that painful. In the meantime, this PR adds sensitve clatifications.
Thanks! |
Fixes #84888