Package com.kenai.jffi
Class ClosurePool.Handle
java.lang.Object
com.kenai.jffi.ClosurePool.Handle
- All Implemented Interfaces:
Closure.Handle
- Enclosing class:
- ClosurePool
Manages the lifecycle of a native closure.
Implements
Closure.Handle
interface.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
(package private) final ClosurePool.MagazineHolder
Keep references to the closure pool so it does not get garbage collected until all closures using it do.(package private) final ClosurePool.Magazine.Slot
-
Constructor Summary
ConstructorsConstructorDescriptionHandle
(ClosurePool.Magazine.Slot slot, ClosurePool.MagazineHolder holder) Creates a new Handle to lifecycle manager the native closure. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Releases the closure memory back to the operating system.void
free()
Deprecated.long
Gets the native code address of the closure.void
setAutoRelease
(boolean autorelease) Sets whether the closure memory should be released when theHandle
is garbage collected or not.
-
Field Details
-
holder
Keep references to the closure pool so it does not get garbage collected until all closures using it do. -
slot
-
disposed
private volatile boolean disposed
-
-
Constructor Details
-
Handle
Handle(ClosurePool.Magazine.Slot slot, ClosurePool.MagazineHolder holder) Creates a new Handle to lifecycle manager the native closure.- Parameters:
slot
- THe magazine slot this handle belongs toholder
- The magazine holder containing this handle
-
-
Method Details
-
getAddress
public long getAddress()Description copied from interface:Closure.Handle
Gets the native code address of the closure. This can be passed into a native function that takes a function pointer.- Specified by:
getAddress
in interfaceClosure.Handle
- Returns:
- The native address of the closure code.
-
setAutoRelease
public void setAutoRelease(boolean autorelease) Description copied from interface:Closure.Handle
Sets whether the closure memory should be released when theHandle
is garbage collected or not.- Specified by:
setAutoRelease
in interfaceClosure.Handle
- Parameters:
autorelease
- If true, the closure memory is automatically managed, else the closure memory must be explicitly freed.
-
free
Deprecated.- Specified by:
free
in interfaceClosure.Handle
-
dispose
public void dispose()Description copied from interface:Closure.Handle
Releases the closure memory back to the operating system. Although the closure trampoline memory will normally be released when theHandle
is garbage collected, this may not happen for some time, and is non-deterministic. This allows explicit control over memory reclamation.- Specified by:
dispose
in interfaceClosure.Handle
-