I just wanted to report back that I have solved this now and thank everyone
for their help.

What I kept running into, which floored me was that with rexx\sql you have
to run the loadfuncs function, when you start on a new thread, even though
rxFuncQuery reports the functions as already loaded.

Once I got that into my head, I could load/unload the functions on each
invocation of the server and the server could shut itself down (after a
suitable quiescent interval - thanks for that hint Rony - saves a great deal
of thrashing)

Jon

On 2 April 2011 19:55, Sahananda (Jon) Wolfers <[email protected]>wrote:

> Hi Bill,
>
> this is the conclusion I had come to when I read Mark last.  I won't start
> the server in the init class method, but anything that uses it will have to
> start it and then stop it when they have finished.  Starting when already
> started will just add to the usage count.  Stopping decreases it and when it
> is 0 it really stops.  It will mean changing my existing code a bit (which I
> had hoped to avoid), but it seems the sensible way to go.
>
> thanks,
>
> Jon
>
> PS: thanks Rony - that gave me something to think about.
>
>
>
>
> On 2 April 2011 19:13, Bill Turner, WB4ALM <[email protected]> wrote:
>
>>  Jon, Can you also implement a global "usage count"?  When the count is
>> zero, the service can shutdown.
>>
>> That way both A and B increment the count by one when they start, and
>> reduce it by one when they terminate when they quit.
>>
>> if somebody else starts then count goes up one more.  Eventually everybody
>> will quit and the count becomes zero.
>> when it is zero the server shuts its self down.
>>
>> Using your example, the count could get to four
>>
>> a script called C calls A (count +1) which calls B (count +1)   [count is
>> now 2]
>> another script D calls B (count +1) then calls A (count +1)   [count is
>> now 4]
>>
>> As CAB processes and each called routine terminates, the count becomes
>> three and two...
>> As DBA processes and each called routine terminates, the count becomes one
>> and zero...
>>
>> This also allows for intertwining...  and when the count is zero, the
>> server could either decide to terminate
>> or go into a "sleep" before terminating.  Maybe a count of "-1" means that
>> we are getting ready to shutdown,
>> so that other routines know to wait before trying to start the server back
>> up...
>>
>> /s/ Bill Turner, wb4alm
>>
>>
>>
>>
>>
>> On 04/02/2011 11:28 AM, Sahananda (Jon) Wolfers wrote:
>>
>> Hi Mark & Gil,
>>
>> thank you both for your help, but I think what it points to is I have not
>> explained myself.
>>
>> Both of those aproaches predicate a single client using the server.  Let's
>> say I have two routines called A & B that both use the server and have
>> reqires directives in their scripts.
>>
>> a script called C calls A which calls B
>> another script D calls B then calls A
>>
>> Whichever way around they are run, the first one 'require'ed will start up
>> the server.
>> If one of them shuts it down when it terminates, then it is not available
>> to the other.
>>
>> My problem is not shutting it down, but rather knowing when it is
>> apropriate to shut it down.
>>
>> I'm sorry that I'm still worrying away at this on the lists after a year
>>
>> Jon
>>
>>  On 2 April 2011 16:06, Mark Miesfeld <[email protected]> wrote:
>>
>>>  On Sat, Apr 2, 2011 at 7:03 AM, Sahananda (Jon) Wolfers <
>>> [email protected]> wrote:
>>>
>>>> I have a question, and I hope it is ok to ask it here.
>>>>
>>>> It has been brought up by my struggle to move my work to 4.0, but if
>>>> solved for me could benefit many people.
>>>>
>>>>
>>>>
>>>> My specific problem is about managing to use rexx/sql with ooRexx 4.0 in
>>>> a multithreaded environment, but it might b better if I ask the list a more
>>>> general question.
>>>>
>>>>
>>>>
>>>> That is, where one has to provide one’s applications with a service that
>>>> continuously runs, what is the best way to set it up, use it and tear it
>>>> down.  This question has become more important in 4.0, because there
>>>> used to be a loophole in ooDialog that allowed one to run methods on the
>>>> ‘main’ thread of a dialog.  Now that has gone, it needs to be done
>>>> properly.
>>>>
>>>>
>>>>
>>>> So for me, because rexx\sql needs to run on the thread that the library
>>>> was loaded on, I have built a little server, I queue message objects on the
>>>> server, and it performs them on the correct thread.  That all works
>>>> very well.  My problem pertains to how to set it up when it is first
>>>> needed, and tear it down when it is finished with.
>>>>
>>>
>>>  Well, as always questions like this are hard to answer without knowing
>>> what your code is doing.
>>>
>>> But, one approach comes directly from what you say above.  If you are
>>> queueing messages to the server, just define a special message that means
>>> "shut  down".  Then when your application is terminating, send it that
>>> message.
>>>
>>> I doubt that there is any one "right" way to do this.
>>>
>>> Another approach is to have some variable that the server checks each
>>> time it enters its processing loop.  If the variable is true, it drops out
>>> of the loop and the thread terminates.  Then when the application is
>>> terminating you set the varible and manually force the server to check if it
>>> needs to process something.
>>>
>>> Again, I'd suggest looking at the sysinfo.rex example in trunk.  It
>>> solves a problem that seems to be similar to yours, every use of OLE has to
>>> be done on the same thread.
>>>
>>> main\samples\windows\oodialog\sysinfo
>>>
>>> --
>>> Mark Miesfeld
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Create and publish websites with WebMatrix
>>> Use the most popular FREE web apps or write code yourself;
>>> WebMatrix provides all the features you need to develop and
>>> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
>>>
>>> _______________________________________________
>>> Oorexx-devel mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>>>
>>>
>>
>> ------------------------------------------------------------------------------
>> Create and publish websites with WebMatrix
>> Use the most popular FREE web apps or write code yourself;
>> WebMatrix provides all the features you need to develop and
>> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
>>
>>
>> _______________________________________________
>> Oorexx-devel mailing 
>> [email protected]https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Create and publish websites with WebMatrix
>> Use the most popular FREE web apps or write code yourself;
>> WebMatrix provides all the features you need to develop and
>> publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
>>
>> _______________________________________________
>> Oorexx-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>>
>>
>
------------------------------------------------------------------------------
Fulfilling the Lean Software Promise
Lean software platforms are now widely adopted and the benefits have been 
demonstrated beyond question. Learn why your peers are replacing JEE 
containers with lightweight application servers - and what you can gain 
from the move. http://p.sf.net/sfu/vmware-sfemails
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to