Re: Stopping a NSRunLoop
Re: Stopping a NSRunLoop
- Subject: Re: Stopping a NSRunLoop
- From: Bill Bumgarner <email@hidden>
- Date: Tue, 23 May 2006 13:18:37 -0700
On May 23, 2006, at 12:49 PM, Andrei Tchijov wrote:
I guess if you can "remove" all sources from RunLopp ... but than it
should stop by itself without CFRunLoopStop ... In my case I needed
to stop RunLoop which was "primed" like this
[[NSRunLoop currentRunLoop] configureAsServer];
combination of getCFRunLoop and CFRunLoopStop did not work, so I end-
up using Apple example
double resolution = 1.0;
BOOL isRunning;
do {
NSDate* next = [NSDate dateWithTimeIntervalSinceNow:resolution];
isRunning = [[NSRunLoop currentRunLoop]
runMode:NSDefaultRunLoopMode beforeDate:next];
} while (isRunning && !endRunLoop);
works great.
You really don't want to do that -- it'll make your loop "busy wait".
That is, it is going to wake up and do something every second,
regardless of whether or not it has anything to do. If the enclosing
app has been hidden, this is going to cause the app to wake up,
consume memory resources that could otherwise be devoted to what the
user is really focused on.
-configureAsServer does absolutely nothing. Zero. Nada. Zilch.
Total no-op.
As per the documentation (for the -run method), your run loop will
stop running once all input sources have been invalidated. Figure
out how to get a hold of and invalidate the input sources as
necessary. That way, your run loop will consume no cycles and
minimal resources when there is no work to be done.
b.bum
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden