mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
([RunLoop -acceptInputForMode:beforeDate:]): If LIMIT_DATE is nil,
poll the inputs, but don't wait if there is nothing available immediately. Check to make sure that the LIMIT_DATE hasn't already past; if it has, return immediately, before polling input sources. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1220 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9874e6ab48
commit
a737a8e65f
1 changed files with 23 additions and 5 deletions
|
@ -25,7 +25,6 @@
|
|||
It is still in the early stages of development, and will most likely
|
||||
evolve quite a bit more before the interface settles.
|
||||
|
||||
Distinguishing between different MODES is not currently implemented.
|
||||
Handling NSTimers is implemented, but currently disabled.
|
||||
|
||||
Does it strike anyone else that NSNotificationCenter,
|
||||
|
@ -239,7 +238,8 @@ static RunLoop *current_run_loop;
|
|||
}
|
||||
|
||||
|
||||
/* Listen to input sources */
|
||||
/* Listen to input sources.
|
||||
If LIMIT_DATE is nil, then don't wait; i.e. call select() with 0 timeout */
|
||||
|
||||
- (void) acceptInputForMode: (id <String>)mode
|
||||
beforeDate: limit_date
|
||||
|
@ -267,9 +267,17 @@ static RunLoop *current_run_loop;
|
|||
#endif
|
||||
|
||||
/* Find out how much time we should wait, and set SELECT_TIMEOUT. */
|
||||
if (limit_date
|
||||
&& ((ti = [limit_date timeIntervalSinceNow]) < LONG_MAX))
|
||||
if (!limit_date)
|
||||
{
|
||||
/* Don't wait at all. */
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
select_timeout = &timeout;
|
||||
}
|
||||
else if ((ti = [limit_date timeIntervalSinceNow]) < LONG_MAX
|
||||
&& ti > 0.0)
|
||||
{
|
||||
/* Wait until the LIMIT_DATE. */
|
||||
if (debug_run_loop)
|
||||
printf ("\tRunLoop accept input before %f (seconds from now %f)\n",
|
||||
[limit_date timeIntervalSinceReferenceDate], ti);
|
||||
|
@ -280,13 +288,19 @@ static RunLoop *current_run_loop;
|
|||
printf ("\tRunLoop limit date past, returning\n");
|
||||
return;
|
||||
}
|
||||
|
||||
timeout.tv_sec = ti;
|
||||
timeout.tv_usec = ti * 1000000.0;
|
||||
select_timeout = &timeout;
|
||||
}
|
||||
else if (ti <= 0.0)
|
||||
{
|
||||
/* The LIMIT_DATE has already past; return immediately without
|
||||
polling any inputs. */
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wait forever. */
|
||||
if (debug_run_loop)
|
||||
printf ("\tRunLoop accept input waiting forever\n");
|
||||
select_timeout = NULL;
|
||||
|
@ -401,6 +415,10 @@ static RunLoop *current_run_loop;
|
|||
[self acceptInputForMode: mode
|
||||
beforeDate: d];
|
||||
|
||||
/* xxx Is this where we detect if the RunLoop is idle, and whether
|
||||
we should dispatch the notifications from NotificationQueue's
|
||||
idle queue? */
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue