public final class ClosureManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
ClosureManager.SingletonHolder
Holder class to do lazy allocation of the ClosureManager instance
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<CallContext,java.lang.ref.Reference<ClosurePool>> |
poolMap
ClosurePool instances are linked via a SoftReference in the lookup map, so
when all closure instances that that were allocated from the ClosurePool have been
reclaimed, and there is memory pressure, the native closure pool can be freed.
|
Modifier | Constructor and Description |
---|---|
private |
ClosureManager()
Constructs a ClosureManager
|
Modifier and Type | Method and Description |
---|---|
ClosurePool |
getClosurePool(CallContext callContext) |
static ClosureManager |
getInstance()
Gets the global instance of the ClosureManager
|
Closure.Handle |
newClosure(Closure closure,
CallContext callContext)
Wraps a java object that implements the
Closure interface in a
native closure. |
Closure.Handle |
newClosure(Closure closure,
Type returnType,
Type[] parameterTypes,
CallingConvention convention)
Wraps a java object that implements the
Closure interface in a
native closure. |
ClosureMagazine |
newClosureMagazine(CallContext callContext,
java.lang.reflect.Method method) |
private final java.util.Map<CallContext,java.lang.ref.Reference<ClosurePool>> poolMap
CallContextCache
public static ClosureManager getInstance()
public final Closure.Handle newClosure(Closure closure, Type returnType, Type[] parameterTypes, CallingConvention convention)
Closure
interface in a
native closure.closure
- The java object to be called when the native closure is invoked.returnType
- The return type of the closure.parameterTypes
- The parameter types of the closure.convention
- The calling convention of the closure.Closure.Handle
instance.public final Closure.Handle newClosure(Closure closure, CallContext callContext)
Closure
interface in a
native closure.closure
- The java object to be called when the native closure is invoked.callContext
- The call context (return type, param types, convention) of the ClosureClosure.Handle
instance.public final ClosurePool getClosurePool(CallContext callContext)
public ClosureMagazine newClosureMagazine(CallContext callContext, java.lang.reflect.Method method)