Re: Proper way to run runloop for DO server?
Re: Proper way to run runloop for DO server?
- Subject: Re: Proper way to run runloop for DO server?
- From: Chris Kane <email@hidden>
- Date: Fri, 21 Mar 2003 10:54:29 -0800
It sounds like you are trying to shut down one thread within a process,
not the entire process. My comments are only addressing when the
entire process (or task in Mach terminology) is to be shut down. The
OS will clean up resources consumed by the process at that point,
including vended objects over DO, so you don't need to worry about
reference counts and the like in that case.
The OS cleanup is more efficient than you trying to do it yourself, as
well.
This doesn't apply to resources, like files, on some type of "permanent
store" like a file system. If you need to clean up those sorts of
things, do that before calling exit().
Chris Kane
Cocoa Framework, Apple
On Thursday, March 20, 2003, at 20:33, email@hidden wrote:
My problem with the following is performing the cleaning of the object
that is
been vended for the connection.
I have used a similar approach - having the client call a shutdown()
method on
the vended object, which would perform cleanup and exit the current
thread.
I have observed though that as long as I have a proxy to the vended
object,
which I would when I call shutdown() from the client - the reference
count does
not go down to 1 when I exit the thread. Thus the vended object's
dealloc()
method does not get called. To circumvent it I explicitly call
[vendedObject
release] after I register the object with the default connection and
then call
[self release] in the shutdown() method to take into account the
existing proxy
for the vended object..
make sense?
Zameer
On Thu, 20 Mar 2003 20:28:20 -0800 (PST), Chris Kane wrote:
On Tuesday, March 18, 2003, at 06:11 PM, Jim Correia wrote:
What is the proper way to run the runloop for a daemon that sits
there
and handles message via distributed objects?
One of the messages it handles is a message that tells it the process
should cleanly exit.
The best bet is to use -run and expect that never to return (but
include
code to handle the case where it might). -run is a convenience to run
forever (so don't use it if you don't want it to run forever), which
is
typical for a server after it's done all its setup.
If you want to quit the server, just exit() after doing any cleanup
you
want to do, upon reaching the triggering condition as a callout from
the
run loop (in your case, while handing the exit message). Figuring out
how to make -run return is a waste of energy, though people often fall
into that trap. When you want to terminate, just do so.
Should I send the current NSRunLoop a configureAsServer message,
then a
run message? Then exit with runloop with CFRunLoopStop when my server
gets the exit message?
-configureAsServer doesn't do anything on Mach, so I wouldn't call it.
Chris Kane
Cocoa Frameworks, Apple
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: <a
href="http://mail.canada.com/jump/http://www.lists.apple.com/mailman/
listinfo/cocoa-dev">http://www.lists.apple.com/mailman/listinfo/cocoa-
dev</a>
Do not post admin requests to the list. They will be ignored.
__________________________________________________________
Get your FREE personalized e-mail at http://www.canada.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.