On 20.07.2022 18:05, Rick McGuire wrote:
When the instance is terminated, all object references are cleared out in case there might be a dangling reference to the instance object that might pin it in memory. This includes .local, which should not be pinned anywhere. I spent fair about of time recently tracing the termination code to fix #1734, so I know it's doing what it's supposed to be doing.

I was going to suggest reverting your overrides before terminating the instance. A more appropriate way to do that is to call the destination method with no argument.

Did that as the first strategy: calling destination until .nil gets returned and then placing back the destination right before it.

The monitor maintains a queue of the destination objects, so this will pop your monitor off of the queue and revert to the previous destination.

Yes. It is possible however that there are Rexx programmers who may put another destination on top of it (hence popping the destinations until getting to the very first one in the first attempts) hence using destination until .nil got returned. (Then changed the logic to simply remove the monitor objects from .local by replacing the monitor objects with new ones that got configured like in the beginning which seems to work as well.)

The only other thing to comes to mind is that you are calling the terminate API on the wrong thread or in the wrong circumstances (e.g., on the correct thread but as the result of a callout from running oorexx code). I know you tried doing the second one once before. Are you checking the you are getting a true return value from the terminate call?

Terminate() is defined to be void (from rexxapi.pdf):

   1.17.187. Terminate
   This API is available in context Instance.
   // Method Syntax Form(s)
   context->Terminate();
   Terminates the current Rexx interpreter instance. Terminate() may only be 
called from the thread
   context that originally created the interpreter instance. This call will 
wait for all threads to
   complete processing before returning.
   Arguments
   None.
   Returns
   Void.

When an instance gets created on the native side it will be stored in a structure together with its Java peer (a jobj) and the Java object representing the Rexx interpreter configuration used when creating the instance (a jobj). That structure then gets placed on a simply linked list on the native side. The Java side gets the context instance pointer returned as a string rendering.

In the use case of termination the native side gets that string, turns it into a RexxInstance pointer and searches it in the linked list. If found it gets used for invoking Terminate(), if not, then a Java exception gets raised.

At operating system thread in which Terminate() gets invoked: this is controlled by Java (in this case by the cleaner of PhantomReferences).

---rony

_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to