[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about NSRunLoop -runUntilDate:
From: |
Richard Frith-Macdonald |
Subject: |
Re: Question about NSRunLoop -runUntilDate: |
Date: |
Mon, 1 Aug 2005 12:45:10 +0100 |
On 1 Aug 2005, at 11:04, Chris Vetter wrote:
On Mon, 01 Aug 2005 08:53:23 Richard Frith-Macdonald wrote:
Maybe this has an obvious answer but if so I can't see it... :-(
The documentation for -runUntilDate: says
Runs the loop in NSDefaultRunLoopMode by repeated calls to
-runMode:beforeDate: while there are still input sources. Exits
when no
more input sources remain, or date is reached, whichever occurs
first.
Yes, I know, but...
So I guess you could send the notification when the method returns.
While the runloop 'runs' for X minutes, it contains a timer that
fires every
Y seconds calling a selector. There is no method 'blocking' the
application,
rather the runloop works in the background.
Do you mean that the runloop is working in another thread?
I was hoping that once the runloop stops, it would invalidate
(which could
be checked) but that doesn't seem to be the case.
No ... runloops never become 'invalid' ... though -limitDateForMode:
will check to see if there are inputs remaining.
Would it be possible to create an observer that checks -
limitDateForMode: ?
As far as I understand its documentation, if there is no timer
scheduled
(anymore) the method should return no date (nil?) -- which would
mean that
the limitDate (used in -runUntilDate:) has been reached.
No ... runloops are meant to be thread-local, and it's not safe to
monitor a runloop running in one thread from an other thread.
If you want a notification when there are no more inputs for a
runloop, you can just use -runUntilDate:
eg.
[[NSRunLoop currentRunLoop] runUntilDate: endDate];
[[NSNotificationCenter defaultCenter] postNotificationName:
@"NoInputsLeft" object: [NSRunLoop currentRunLoop]];
// continue processing in this thread.