Jon, Let me suggest an alternate way of approaching the problem. Instead of the server trying to determine if it should shut down, have it understand a message object that means "shut yourself down". Now you have moved the problem back to the main code which needs to have a "last" script - one that runs after all the other scripts that use the server have terminated - and that sends the "shut yourself down" message to the server before exiting.
Sahananda (Jon) Wolfers 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. > > > > I can set it up and start it running, by doing so in the CLASS INIT > method. This means that the first script that includes the server class > in a ::REQUIRES directive loads the rexx\sql libraries and kicks off the > server. > > > > Subsequent scripts may be loaded which ‘require’ the server class, and > it is there and running. > > > > However, when all the client scripts have finished and terminated, the > server is still sitting there all alone running, and my interpreter > instance won’t terminate. > > > > Is there some mechanism by which the server can know that everything > else has terminated and it is alone in the world? > > > > Ancillary to that question was a question I asked on the RexxLA list, > which was, if you have a process which ‘runs on’ in this fashion, is > there some way to detect which method is still ‘active’ (I use the word > active advisedly, as it is probably in a guarded state). > > > > Many thanks, > > > > Jon > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > 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 > Oorexx-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/oorexx-devel -- Gil Barmwater ------------------------------------------------------------------------------ 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 Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel