Package com.kenai.jffi
Class ClosurePool.Handle
- java.lang.Object
-
- com.kenai.jffi.ClosurePool.Handle
-
- All Implemented Interfaces:
Closure.Handle
- Enclosing class:
- ClosurePool
private static final class ClosurePool.Handle extends java.lang.Object implements Closure.Handle
Manages the lifecycle of a native closure. ImplementsClosure.Handleinterface.
-
-
Field Summary
Fields Modifier and Type Field Description private booleandisposed(package private) ClosurePool.MagazineHolderholderKeep references to the closure pool so it does not get garbage collected until all closures using it do.(package private) ClosurePool.Magazine.Slotslot
-
Constructor Summary
Constructors Constructor Description Handle(ClosurePool.Magazine.Slot slot, ClosurePool.MagazineHolder holder)Creates a new Handle to lifecycle manager the native closure.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voiddispose()Releases the closure memory back to the operating system.voidfree()Deprecated.longgetAddress()Gets the native code address of the closure.voidsetAutoRelease(boolean autorelease)Sets whether the closure memory should be released when theHandleis garbage collected or not.
-
-
-
Field Detail
-
holder
final ClosurePool.MagazineHolder holder
Keep references to the closure pool so it does not get garbage collected until all closures using it do.
-
slot
final ClosurePool.Magazine.Slot slot
-
disposed
private volatile boolean disposed
-
-
Constructor Detail
-
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 Detail
-
getAddress
public long getAddress()
Description copied from interface:Closure.HandleGets the native code address of the closure. This can be passed into a native function that takes a function pointer.- Specified by:
getAddressin interfaceClosure.Handle- Returns:
- The native address of the closure code.
-
setAutoRelease
public void setAutoRelease(boolean autorelease)
Description copied from interface:Closure.HandleSets whether the closure memory should be released when theHandleis garbage collected or not.- Specified by:
setAutoReleasein interfaceClosure.Handle- Parameters:
autorelease- If true, the closure memory is automatically managed, else the closure memory must be explicitly freed.
-
free
@Deprecated public void free()
Deprecated.- Specified by:
freein interfaceClosure.Handle
-
dispose
public void dispose()
Description copied from interface:Closure.HandleReleases the closure memory back to the operating system. Although the closure trampoline memory will normally be released when theHandleis garbage collected, this may not happen for some time, and is non-deterministic. This allows explicit control over memory reclamation.- Specified by:
disposein interfaceClosure.Handle
-
-