:right-sidebar: True TaskPool =================================================================== .. currentmodule:: gi.repository.Gst .. class:: TaskPool(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gst.Object`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gst.SharedTaskPool` This object provides an abstraction for creating threads. The default implementation uses a regular GThreadPool to start tasks. Subclasses can be made to create custom threads. Constructors ------------ .. rst-class:: interim-class .. class:: TaskPool :no-index: .. classmethod:: new() -> ~gi.repository.Gst.TaskPool Create a new default task pool. The default task pool will use a regular GThreadPool for threads. Methods ------- .. rst-class:: interim-class .. class:: TaskPool :no-index: .. method:: cleanup() -> None Wait for all tasks to be stopped. This is mainly used internally to ensure proper cleanup of internal data structures in test suites. MT safe. .. method:: dispose_handle(id: ~typing.Any = None) -> None Dispose of the handle returned by :func:`~gi.repository.Gst.TaskPool.push`. This does not need to be called with the default implementation as the default :obj:`~gi.repository.Gst.TaskPoolClass`\::push implementation always returns :const:`None`. This does not need to be called either when calling :func:`~gi.repository.Gst.TaskPool.join`, but should be called when joining is not necessary, but :func:`~gi.repository.Gst.TaskPool.push` returned a non-:const:`None` value. This method should only be called with the same ``pool`` instance that provided ``id``\. .. versionadded:: 1.20 :param id: the id .. method:: do_cleanup(self) -> None .. method:: do_dispose_handle(self, id: ~typing.Any = None) -> None :param id: .. method:: do_join(self, id: ~typing.Any = None) -> None :param id: .. method:: do_prepare(self) -> None .. method:: do_push(self, func: ~typing.Callable[[~typing.Any], None], user_data: ~typing.Any = None) -> ~typing.Any | None :param func: :param user_data: .. method:: join(id: ~typing.Any = None) -> None Join a task and/or return it to the pool. ``id`` is the id obtained from :func:`~gi.repository.Gst.TaskPool.push`. The default implementation does nothing, as the default :obj:`~gi.repository.Gst.TaskPoolClass`\::push implementation always returns :const:`None`. This method should only be called with the same ``pool`` instance that provided ``id``\. :param id: the id .. method:: prepare() -> None Prepare the taskpool for accepting :func:`~gi.repository.Gst.TaskPool.push` operations. MT safe. .. method:: push(func: ~typing.Callable[[~typing.Any], None], user_data: ~typing.Any = None) -> ~typing.Any | None Start the execution of a new thread from ``pool``\. :param func: the function to call :param user_data: data to pass to ``func`` Virtual Methods --------------- .. rst-class:: interim-class .. class:: TaskPool :no-index: .. method:: do_cleanup() -> None Wait for all tasks to be stopped. This is mainly used internally to ensure proper cleanup of internal data structures in test suites. MT safe. .. method:: do_dispose_handle(id: ~typing.Any = None) -> None Dispose of the handle returned by :func:`~gi.repository.Gst.TaskPool.push`. This does not need to be called with the default implementation as the default :obj:`~gi.repository.Gst.TaskPoolClass`\::push implementation always returns :const:`None`. This does not need to be called either when calling :func:`~gi.repository.Gst.TaskPool.join`, but should be called when joining is not necessary, but :func:`~gi.repository.Gst.TaskPool.push` returned a non-:const:`None` value. This method should only be called with the same ``pool`` instance that provided ``id``\. .. versionadded:: 1.20 :param id: the id .. method:: do_join(id: ~typing.Any = None) -> None Join a task and/or return it to the pool. ``id`` is the id obtained from :func:`~gi.repository.Gst.TaskPool.push`. The default implementation does nothing, as the default :obj:`~gi.repository.Gst.TaskPoolClass`\::push implementation always returns :const:`None`. This method should only be called with the same ``pool`` instance that provided ``id``\. :param id: the id .. method:: do_prepare() -> None Prepare the taskpool for accepting :func:`~gi.repository.Gst.TaskPool.push` operations. MT safe. .. method:: do_push(func: ~typing.Callable[[~typing.Any], None], user_data: ~typing.Any = None) -> ~typing.Any | None Start the execution of a new thread from ``pool``\. :param func: the function to call :param user_data: data to pass to ``func`` Fields ------ .. rst-class:: interim-class .. class:: TaskPool :no-index: .. attribute:: object .. attribute:: pool