Class SourceFuncs

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class SourceFuncs extends ProxyInstance

The GSourceFuncs struct contains a table of functions used to handle event sources in a generic manner.

For idle sources, the prepare and check functions always return true to indicate that the source is always ready to be processed. The prepare function also returns a timeout value of 0 to ensure that the poll() call doesn't block (since that would be time wasted which could have been spent running the idle function).

For timeout sources, the prepare and check functions both return true if the timeout interval has expired. The prepare function also returns a timeout value to ensure that the poll() call doesn't block too long and miss the next timeout.

For file descriptor sources, the prepare function typically returns false, since it must wait until poll() has been called before it knows whether any events need to be processed. It sets the returned timeout to -1 to indicate that it doesn't mind how long the poll() call blocks. In the check function, it tests the results of the poll() call to see if the required condition has been met, and returns true if so.

  • Constructor Details

    • SourceFuncs

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

      public SourceFuncs(Arena arena)
      Allocate a new SourceFuncs.
      Parameters:
      arena - to control the memory allocation scope
    • SourceFuncs

      public SourceFuncs()
      Allocate a new SourceFuncs. The memory is allocated with Arena.ofAuto().
    • SourceFuncs

      public SourceFuncs(SourceFuncsPrepareFunc prepare, SourceFuncsCheckFunc check, SourceFuncsDispatchFunc dispatch, SourceFuncsFinalizeFunc finalize_, SourceFunc closureCallback, SourceDummyMarshal closureMarshal, Arena arena)
      Allocate a new SourceFuncs with the fields set to the provided values.
      Parameters:
      prepare - value for the field prepare
      check - value for the field check
      dispatch - value for the field dispatch
      finalize_ - value for the field finalize_
      closureCallback - value for the field closureCallback
      closureMarshal - value for the field closureMarshal
      arena - to control the memory allocation scope
    • SourceFuncs

      public SourceFuncs(SourceFuncsPrepareFunc prepare, SourceFuncsCheckFunc check, SourceFuncsDispatchFunc dispatch, SourceFuncsFinalizeFunc finalize_, SourceFunc closureCallback, SourceDummyMarshal closureMarshal)
      Allocate a new SourceFuncs with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      prepare - value for the field prepare
      check - value for the field check
      dispatch - value for the field dispatch
      finalize_ - value for the field finalize_
      closureCallback - value for the field closureCallback
      closureMarshal - value for the field closureMarshal
  • Method Details

    • getMemoryLayout

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

      public @Nullable SourceFuncsPrepareFunc readPrepare()
      Read the value of the field prepare.
      Returns:
      The value of the field prepare
    • writePrepare

      public void writePrepare(@Nullable SourceFuncsPrepareFunc prepare, Arena _arena)
      Write a value in the field prepare.
      Parameters:
      prepare - The new value for the field prepare
      _arena - to control the memory allocation scope
    • readCheck

      public @Nullable SourceFuncsCheckFunc readCheck()
      Read the value of the field check.
      Returns:
      The value of the field check
    • writeCheck

      public void writeCheck(@Nullable SourceFuncsCheckFunc check, Arena _arena)
      Write a value in the field check.
      Parameters:
      check - The new value for the field check
      _arena - to control the memory allocation scope
    • readDispatch

      public @Nullable SourceFuncsDispatchFunc readDispatch()
      Read the value of the field dispatch.
      Returns:
      The value of the field dispatch
    • writeDispatch

      public void writeDispatch(@Nullable SourceFuncsDispatchFunc dispatch, Arena _arena)
      Write a value in the field dispatch.
      Parameters:
      dispatch - The new value for the field dispatch
      _arena - to control the memory allocation scope
    • readFinalize

      public @Nullable SourceFuncsFinalizeFunc readFinalize()
      Read the value of the field finalize.
      Returns:
      The value of the field finalize
    • writeFinalize

      public void writeFinalize(@Nullable SourceFuncsFinalizeFunc finalize_, Arena _arena)
      Write a value in the field finalize.
      Parameters:
      finalize_ - The new value for the field finalize
      _arena - to control the memory allocation scope
    • readClosureCallback

      public @Nullable SourceFunc readClosureCallback()
      Read the value of the field closure_callback.
      Returns:
      The value of the field closure_callback
    • writeClosureCallback

      public void writeClosureCallback(@Nullable SourceFunc closureCallback, Arena _arena)
      Write a value in the field closure_callback.
      Parameters:
      closureCallback - The new value for the field closure_callback
      _arena - to control the memory allocation scope
    • readClosureMarshal

      public @Nullable SourceDummyMarshal readClosureMarshal()
      Read the value of the field closure_marshal.
      Returns:
      The value of the field closure_marshal
    • writeClosureMarshal

      public void writeClosureMarshal(@Nullable SourceDummyMarshal closureMarshal, Arena _arena)
      Write a value in the field closure_marshal.
      Parameters:
      closureMarshal - The new value for the field closure_marshal
      _arena - to control the memory allocation scope