Class TaskPool

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
SharedTaskPool

@Generated("org.javagi.JavaGI") public class TaskPool extends GstObject

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.

  • Constructor Details

    • TaskPool

      public TaskPool(MemorySegment address)
      Create a TaskPool instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • TaskPool

      public TaskPool()
      Create a new TaskPool.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the TaskPool class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected TaskPool asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GstObject
      Returns:
      the instance as if it were its parent type
    • cleanup

      public void cleanup()

      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.

    • disposeHandle

      public void disposeHandle(@Nullable MemorySegment id)

      Dispose of the handle returned by gst_task_pool_push(). This does not need to be called with the default implementation as the default GstTaskPoolClass::push implementation always returns null. This does not need to be called either when calling gst_task_pool_join(), but should be called when joining is not necessary, but gst_task_pool_push() returned a non-null value.

      This method should only be called with the same this TaskPool instance that provided id.

      Parameters:
      id - the id
      Since:
      1.20
    • join

      public void join(@Nullable MemorySegment id)

      Join a task and/or return it to the pool. id is the id obtained from gst_task_pool_push(). The default implementation does nothing, as the default GstTaskPoolClass::push implementation always returns null.

      This method should only be called with the same this TaskPool instance that provided id.

      Parameters:
      id - the id
    • prepare

      public void prepare() throws GErrorException

      Prepare the taskpool for accepting gst_task_pool_push() operations.

      MT safe.

      Throws:
      GErrorException - see GError
    • push

      public @Nullable MemorySegment push(@Nullable TaskPoolFunction func) throws GErrorException
      Start the execution of a new thread from pool.
      Parameters:
      func - the function to call
      Returns:
      a pointer that should be used for the gst_task_pool_join function. This pointer can be null, you must check error to detect errors. If the pointer is not null and gst_task_pool_join() is not used, call gst_task_pool_dispose_handle() instead.
      Throws:
      GErrorException - see GError
    • builder

      public static TaskPool.Builder<? extends TaskPool.Builder> builder()
      A TaskPool.Builder object constructs a TaskPool with the specified properties. Use the various set...() methods to set properties, and finish construction with TaskPool.Builder.build().
      Returns:
      the builder object