public class RexxCleanupRef
extends java.lang.ref.PhantomReference
PhantomReferences
for cleanup actions in these two cases:
To not block termination of Rexx the cleanup thread does not use the blocking remove()
method on the reference queue, but rather remove(timeout)
and terminates when the
queue is empty. To make sure that the cleanup gets carried out eventually, each time a new
instance of this class gets created the @link{RexxCleanupRef#startCleanerThread()} method gets invoked, if
it is not running. From time to time the static method @link{RexxCleanupRef#startCleanerThread()} gets invoked
by BSF4ooRexx directly in the RexxAndJava
class.
------------------------ Apache Version 2.0 license ------------------------- Copyright (C) 2021-2022 Rony G. Flatscher Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------------
Modifier and Type | Class and Description |
---|---|
static class |
RexxCleanupRef.RefKind
Defines the valid kinds of Rexx related resources to finalize.
|
Modifier and Type | Field and Description |
---|---|
static java.util.IdentityHashMap<RexxCleanupRef,java.lang.Object> |
pinnedReferences
Learned that
PhantomReferences must be refenced themselves
otherwise they may never be put on the reference queue, so storing them
in this IdentityHashMap until the reference is being put on
the reference queue for processing, at which time the reference will be
removed from the IdentityHashMap . |
static java.lang.String |
version
Version string indicating version of this class (majorVersion*100+minorVersion
concatenated with a dot and the sorted date of last change.
|
Constructor and Description |
---|
RexxCleanupRef(java.lang.Object referent,
RexxCleanupRef.RefKind refKind,
java.lang.Object obj_id)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static int |
getCleanInvocationCounter()
Getter method.
|
static long[][] |
getCounters()
Getter that returns a clone (copy) of the current counters array indexed by ordinal value of
RefKind in first dimension, and by 0 (created instances) and 1 (finalizers ran). |
static boolean |
getDebugRexxProxy()
Getter for
bDebugRexxProxy . |
static boolean |
getDebugRII()
Returns the current setting of the private boolean field
|
static int |
getGcThreshold()
Threshold of unfinalized RexxEngines which will cause a System.gc() to be called.
|
static int |
getGcThresholdMax()
Return gcThresholdMax attribute.
|
static int |
getGcThresholdMin()
Return gcThresholdMin attribute.
|
static RexxCleanupRef.RefKind[] |
getRefkinds()
Getter that returns a clone (copy) of the enum constants of the @link{RefKind} enum class.
|
static java.lang.String |
getStatistics()
Creates a string with formatted instances, finalizes and not yet finalized objects grouped by
|
static java.lang.String |
getStatistics(java.lang.String title)
Creates a string with formatted instances, finalizes and not yet finalized objects grouped by
|
protected int |
jniRexxTerminateInterpreterInstance(java.lang.String rii_ID) |
protected int |
jniUnregisterRexxObject(java.lang.String obj_ID)
Unregisters the Rexx object denoted by 'obj_ID' from the JNI registry.
|
static void |
main(java.lang.String[] args) |
static void |
setDebugRexxProxy(boolean newDebugState)
Setter for
bDebugRexxProxy . |
static void |
setDebugRII(boolean newDebugState)
Allows changing Setter for
bDebugRII (Rexx interpreter instance related). |
static void |
setGcThreshold(int newValue)
Set threshold of unfinalized RexxEngines which will cause a System.gc() to
be called.
|
static void |
setGcThresholdMax(int newValue)
Set gcThresholdMin attribute:
newValue>=gcThresholdMin . |
static void |
setGcThresholdMin(int newValue)
Set gcThresholdMin attribute:
newValue>=1 && newValue<=gcThresholdMax . |
public static final java.lang.String version
public static final java.util.IdentityHashMap<RexxCleanupRef,java.lang.Object> pinnedReferences
PhantomReferences
must be refenced themselves
otherwise they may never be put on the reference queue, so storing them
in this IdentityHashMap
until the reference is being put on
the reference queue for processing, at which time the reference will be
removed from the IdentityHashMap
. The IdentityHashMap
gets used as IdentityHashSet
, i.e. the value part will always
be null.public RexxCleanupRef(java.lang.Object referent, RexxCleanupRef.RefKind refKind, java.lang.Object obj_id)
referent
- the RexxEngine or RexxProxy object to watchrefKind
- RexxCleanupRef.obj_id
- the string id maintained in native code or RexxEngine of finalized RexxScriptEngine
or the RexxEngine instance peer of the RexxScriptEngine instancepublic static boolean getDebugRII()
true
then showing debug message when terminating Rexx interpreter instance)public static void setDebugRII(boolean newDebugState)
bDebugRII
(Rexx interpreter instance related).newDebugState
- if true
then showing a debug message when terminating a Rexx interpreter instancepublic static boolean getDebugRexxProxy()
bDebugRexxProxy
.true
then showing debug message when dereferencing a RexxProxy)public static void setDebugRexxProxy(boolean newDebugState)
bDebugRexxProxy
.newDebugState
- if true
then showing a debug message when dereferencing a RexxProxypublic static int getCleanInvocationCounter()
public static RexxCleanupRef.RefKind[] getRefkinds()
public static long[][] getCounters()
RefKind
in first dimension, and by 0 (created instances) and 1 (finalizers ran).public static int getGcThresholdMin()
public static void setGcThresholdMin(int newValue)
newValue>=1 && newValue<=gcThresholdMax
.newValue
- public static int getGcThresholdMax()
public static void setGcThresholdMax(int newValue)
newValue>=gcThresholdMin
.newValue
- public static int getGcThreshold()
public static void setGcThreshold(int newValue)
newValue
- number of unfinalized RexxEngines that will cause an out of bound
System.gc() to be triggered (to reclaim unused BSF4ooRexx resources)protected int jniRexxTerminateInterpreterInstance(java.lang.String rii_ID)
protected int jniUnregisterRexxObject(java.lang.String obj_ID)
obj_ID
- the object id that is used as a key on the JNI sidepublic static void main(java.lang.String[] args)
public static java.lang.String getStatistics()
public static java.lang.String getStatistics(java.lang.String title)
title
- to be included in the header line at the top