Class SourceFuncs
- All Implemented Interfaces:
Proxy
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 Summary
ConstructorDescriptionAllocate a new SourceFuncs.SourceFuncs
(Arena arena) Allocate a new SourceFuncs.SourceFuncs
(MemorySegment address) Create a SourceFuncs proxy instance for the provided memory address.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.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. -
Method Summary
Modifier and TypeMethodDescriptionstatic MemoryLayout
The memory layout of the native struct.Read the value of the fieldcheck
.Read the value of the fieldclosure_callback
.Read the value of the fieldclosure_marshal
.Read the value of the fielddispatch
.Read the value of the fieldfinalize
.Read the value of the fieldprepare
.void
writeCheck
(SourceFuncsCheckFunc check, Arena _arena) Write a value in the fieldcheck
.void
writeClosureCallback
(SourceFunc closureCallback, Arena _arena) Write a value in the fieldclosure_callback
.void
writeClosureMarshal
(SourceDummyMarshal closureMarshal, Arena _arena) Write a value in the fieldclosure_marshal
.void
writeDispatch
(SourceFuncsDispatchFunc dispatch, Arena _arena) Write a value in the fielddispatch
.void
writeFinalize
(SourceFuncsFinalizeFunc finalize_, Arena _arena) Write a value in the fieldfinalize
.void
writePrepare
(SourceFuncsPrepareFunc prepare, Arena _arena) Write a value in the fieldprepare
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
SourceFuncs
Create a SourceFuncs proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
SourceFuncs
Allocate a new SourceFuncs.- Parameters:
arena
- to control the memory allocation scope
-
SourceFuncs
public SourceFuncs()Allocate a new SourceFuncs. The memory is allocated withArena.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 fieldprepare
check
- value for the fieldcheck
dispatch
- value for the fielddispatch
finalize_
- value for the fieldfinalize_
closureCallback
- value for the fieldclosureCallback
closureMarshal
- value for the fieldclosureMarshal
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 withArena.ofAuto()
.- Parameters:
prepare
- value for the fieldprepare
check
- value for the fieldcheck
dispatch
- value for the fielddispatch
finalize_
- value for the fieldfinalize_
closureCallback
- value for the fieldclosureCallback
closureMarshal
- value for the fieldclosureMarshal
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readPrepare
Read the value of the fieldprepare
.- Returns:
- The value of the field
prepare
-
writePrepare
Write a value in the fieldprepare
.- Parameters:
prepare
- The new value for the fieldprepare
_arena
- to control the memory allocation scope
-
readCheck
Read the value of the fieldcheck
.- Returns:
- The value of the field
check
-
writeCheck
Write a value in the fieldcheck
.- Parameters:
check
- The new value for the fieldcheck
_arena
- to control the memory allocation scope
-
readDispatch
Read the value of the fielddispatch
.- Returns:
- The value of the field
dispatch
-
writeDispatch
Write a value in the fielddispatch
.- Parameters:
dispatch
- The new value for the fielddispatch
_arena
- to control the memory allocation scope
-
readFinalize
Read the value of the fieldfinalize
.- Returns:
- The value of the field
finalize
-
writeFinalize
Write a value in the fieldfinalize
.- Parameters:
finalize_
- The new value for the fieldfinalize
_arena
- to control the memory allocation scope
-
readClosureCallback
Read the value of the fieldclosure_callback
.- Returns:
- The value of the field
closure_callback
-
writeClosureCallback
Write a value in the fieldclosure_callback
.- Parameters:
closureCallback
- The new value for the fieldclosure_callback
_arena
- to control the memory allocation scope
-
readClosureMarshal
Read the value of the fieldclosure_marshal
.- Returns:
- The value of the field
closure_marshal
-
writeClosureMarshal
Write a value in the fieldclosure_marshal
.- Parameters:
closureMarshal
- The new value for the fieldclosure_marshal
_arena
- to control the memory allocation scope
-