Persistent Vs Super Procedure

lemara

New Member
Hello Guys,

I am new to Progress and just wondering if somebody could enlighten me about
persistant procedure and superprocedure, advantages, and difference.

Thanks in advance !

Regards,
lemara
 

lemara

New Member
Super Vs Persistent

Hello,

I am sorry I found the answer here(searcged few Old threads), but can somebody give me an idea about the advantages of Super procedure over Persistent Procedure.

Thanks
Lemara
 
A persistent procedure is a procedure which stays (ie. 'persists') in memory after it has been initialised, until you explicitly delete it. They are most useful for implementing libraries of methods (ie. procedures and functions) which have some commonality of purpose, eg. a string manipulation library, or a library which deals mostly with Accounts business logic.

To run the procedures contained in the library, you need to specify the handle of the persistent procedure. This can be a little unwieldy when you want the pp to be accessed throughout the session.

A super procedure is essentially a persistent procedure which can be accessed without using the handle references. It is added to the session stack, and its internal procedures can be called like any normal internal procedure, although function calls need to be handled a bit differently.

HTH

Lee
 

storzi

Member
A persistent procedure is a procedure which stays (ie. 'persists') in memory after it has been initialised, until you explicitly delete it.
How do I delete persistent procedure?
For example: when I run a window-file (*.w) persistent, do I automatically delete it when I close it?
Or do the window-file stays in memory anyway?
 

storzi

Member
I have put
Code:
DELETE PROCEDURE THIS-PROCEDURE.
in the "WINDOW-CLOSE" - trigger.
But when I check the remaining persistent procedures in the session, there remains the sub-procedures from the closed procedure.

For example:

I start a program "test1.w":

Before the following "run" I check the number of persistent procedures in the session:
Code:
    hTest = SESSION:FIRST-PROCEDURE.
    DO WHILE VALID-HANDLE(hTest):
        i = i + 1.
        hTest = hTest:NEXT-SIBLING.
    END.
Then I start test2.w:
Code:
RUN  test2.w  PERSISTENT .
in test2.w I put
Code:
DELETE PROCEDURE THIS-PROCEDURE.
in the "WINDOW-CLOSE" - trigger.

Then I close test2.w

In test1.w I again check the number of persistent procedures in the session and get the same result as for the first time.
I also get the same result when I remove
Code:
 DELETE PROCEDURE THIS-PROCEDURE.
from test2.w.

In this example everything is fine.

But when test2.w call other programs, these programs will stay in memory although test2.w have been closed (indifferent if I have
Code:
  DELETE PROCEDURE THIS-PROCEDURE.
or not in the "WINDOW-CLOSE"-trigger.

How can I delete those sub-programs (called in test2.w)?
 

tamhas

ProgressTalk.com Sponsor
A procedure doesn't delete itself. The procedure that created it should delete it ... and then set the handle to ?.

General rule in ABL ... if you create it, you are responsible for deleting it.
 

storzi

Member
But there is no delete-statement in test1.w.
And after I close test2.w this program is not available in the session
(SESSION:FIRST-PROCEDURE / :NEXT-SIBLING...).

Also when I look with "protools/_ppmgr.w" there is no entry in the "procedure objects" - list on the left side about test2.w after I closed it...
?
 

DevTeam

Member
General rule in ABL ... if you create it, you are responsible for deleting it.

That's even a general rule in OO programing (=> Object life cycle), but some languages, such as Java, handle this by themselves through internal processes.
 

DevTeam

Member
I have put
Code:
RUN  test2.w  PERSISTENT .
[/quote]

I think that's where the problem is... What if you do a 
[code]
DEF VAR myHandle AS HANDLE NO-UNDO.
RUN  test2.w  PERSISTENT SET myHandle.
and then do
Code:
IF VALID-HANDLE myHandle
THEN DELETE PROCEDURE myHandle.
in the program which called the test2.w
 

storzi

Member
When should I do the
Code:
IF VALID-HANDLE myHandle
THEN DELETE PROCEDURE myHandle.
?

But why?
There is nothing to delete, when test2.w was closed...
 

Casper

ProgressTalk.com Moderator
Staff member
Like tamhas said:

Originally Posted by tamhas
General rule in ABL ... if you create it, you are responsible for deleting it.

So if your test2.w procedure runs some other procedures persistent then test2.w is responsible for keeping track of their handles and cleaning them up. So on the close of test2 the other persistent procedures should be cleaned up.

Casper.
 

storzi

Member
Ok.

But my test2.w is not in the procedure-list after I close it.
Even when test1.w is already running (which runs the test2.w).

The matter is the following:

we have a trigger in a "create menu-item" - statement.

Code:
CREATE MENU-ITEM menu-sub3[i3]
ASSIGN PARENT = menu-sub2[i2]
LABEL = MenueText
TRIGGERS:
ON CHOOSE PERSISTENT RUN ProgStart IN THIS-PROCEDURE (ProgName).
END TRIGGERS.
In ProgStart we call the "ProgName":
Code:
    DEF INPUT PARAM aktion AS CHAR NO-UNDO.
    RUN  VALUE ( aktion ).
If we omit the persistent-parameter in the run-statement, it sometimes happens, that the Menu-Trigger which starts the "ProgStart"-Procedure doesn`t fire.

If we add the persistent-parameter, some procedures stay in memory after they closed.
 

tamhas

ProgressTalk.com Sponsor
And yes, we are supposed to get some kind of garbage collection in some release this year, maybe 10.2, but myself I prefer to take out my own garbage.
 

Casper

ProgressTalk.com Moderator
Staff member
Ok.

But my test2.w is not in the procedure-list after I close it.
Even when test1.w is already running (which runs the test2.w).

The matter is the following:

we have a trigger in a "create menu-item" - statement.

Code:
CREATE MENU-ITEM menu-sub3[i3]
ASSIGN PARENT = menu-sub2[i2]
LABEL = MenueText
TRIGGERS:
ON CHOOSE PERSISTENT RUN ProgStart IN THIS-PROCEDURE (ProgName).
END TRIGGERS.
In ProgStart we call the "ProgName":
Code:
    DEF INPUT PARAM aktion AS CHAR NO-UNDO.
    RUN  VALUE ( aktion ).
If we omit the persistent-parameter in the run-statement, it sometimes happens, that the Menu-Trigger which starts the "ProgStart"-Procedure doesn`t fire.

If we add the persistent-parameter, some procedures stay in memory after they closed.

Oh, triggers.
Do you have a "create widget-pool" statement at the beginning of the program?


Casper
 

tamhas

ProgressTalk.com Sponsor
One of the things I think Casper is pointing out to you here, indirectly, is that the other program is not actually run persistently.

Hence, it doesn't exist when it completes and there is nothing to delete.

Seems like we need to rewind and find out what the actual problem is here.
 

storzi

Member
Oh, triggers.
Do you have a "create widget-pool" statement at the beginning of the program?
Yes. At the beginning of the definitions-block.

One of the things I think Casper is pointing out to you here, indirectly, is that the other program is not actually run persistently.
With:
RUN "protools/_ppmgr.w".
I can see the program in the procedure-objects-list while it is open.
 

tamhas

ProgressTalk.com Sponsor
Right ... it is open while it is open, but not when its not. A persistent procedure hangs around until explicitly deleted.
 
Top