Avoid exposing pthread details in NSLock.h (as much as possible without

impacting performance).


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28612 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-09-06 10:56:04 +00:00
parent e772c54dfa
commit b367e467d6
8 changed files with 929 additions and 18 deletions

View file

@ -27,6 +27,9 @@
// them. Other platforms have more sensible libcs, which just default to being
// standards-compliant.
#define _XOPEN_SOURCE 500
#define gs_cond_t pthread_cond_t
#define gs_mutex_t pthread_mutex_t
#include <pthread.h>
#include "Foundation/NSLock.h"
#include <math.h>
#include <errno.h>

View file

@ -940,7 +940,7 @@ static inline BOOL timerInvalidated(NSTimer *t)
GSIArrayRemoveItemAtIndex(timers, i);
}
}
for (i = 0; recheck == NO && i < GSIArrayCount(timers); i++)
for (i = 0; i < GSIArrayCount(timers); i++)
{
NSDate *d;
@ -1025,6 +1025,27 @@ static inline BOOL timerInvalidated(NSTimer *t)
* the context.
*/
recheck = YES;
/* It's possible that the system time was changed
* while we have been running, and that the timer
* which just fired caused another timer to be
* scheduled using a time in the past relative to
* 'now'. If we checked it again, we would fire it
* again and could in this way end up repeatedly
* firing a timer as fast as we possibly can until
* the system time in in sync with 'now'.
* To prevent this, we re-cache 'now' with the
* current system time if that time is in the past.
* We can't do that unconditionally though, because
* doing so would defeat the whole point of caching
* 'now' ... to prevent a repeated slow timed event
* from continually firing.
*/
ti = GSTimeNow();
if (ti < now)
{
now = ti;
}
break;
}
else
{