diff options
author | reduz <reduzio@gmail.com> | 2022-07-18 12:09:19 +0200 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2022-07-22 11:46:48 +0200 |
commit | 67a260d63f971a6dca2b8716a220831928661085 (patch) | |
tree | b316d47e6cd8de6a11e412150deadedc950367a0 /doc/classes/WorkerThreadPool.xml | |
parent | ed926c4ec1cfadf7e6891e03073e517407ad8d05 (diff) |
Implement a Worker ThreadPool
This PR implements a worked thread pool. It uses a fixed amount of threads in a pool and allows scheduling tasks
that can be run on threads (and then waited for). It satisfies the following use cases:
* HTML5 thread count is fixed (and similar restrictions are known in consoles) so we need to reuse threads.
* Thread spawning is slow in general, so reusing threads is faster anyway.
* This implementation supports recursive waiting for tasks, making it less prone to deadlocks if threads from the pool also run tasks.
After this is approved and merged, subsequent PRs will be needed to replace the ThreadWorkPool usage by this class.
Diffstat (limited to 'doc/classes/WorkerThreadPool.xml')
-rw-r--r-- | doc/classes/WorkerThreadPool.xml | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/doc/classes/WorkerThreadPool.xml b/doc/classes/WorkerThreadPool.xml new file mode 100644 index 0000000000..22eabf9012 --- /dev/null +++ b/doc/classes/WorkerThreadPool.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="WorkerThreadPool" inherits="Object" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="add_group_task"> + <return type="int" /> + <argument index="0" name="action" type="Callable" /> + <argument index="1" name="elements" type="int" /> + <argument index="2" name="tasks_needed" type="int" default="-1" /> + <argument index="3" name="high_priority" type="bool" default="false" /> + <argument index="4" name="description" type="String" default="""" /> + <description> + </description> + </method> + <method name="add_task"> + <return type="int" /> + <argument index="0" name="action" type="Callable" /> + <argument index="1" name="high_priority" type="bool" default="false" /> + <argument index="2" name="description" type="String" default="""" /> + <description> + </description> + </method> + <method name="is_group_task_completed" qualifiers="const"> + <return type="bool" /> + <argument index="0" name="group_id" type="int" /> + <description> + </description> + </method> + <method name="is_task_completed" qualifiers="const"> + <return type="bool" /> + <argument index="0" name="task_id" type="int" /> + <description> + </description> + </method> + <method name="wait_for_group_task_completion"> + <return type="void" /> + <argument index="0" name="group_id" type="int" /> + <description> + </description> + </method> + <method name="wait_for_task_completion"> + <return type="void" /> + <argument index="0" name="task_id" type="int" /> + <description> + </description> + </method> + </methods> +</class> |