mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Improve code for sleeping a bit.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17244 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
97d8f4c387
commit
8a854b2141
6 changed files with 2644 additions and 1581 deletions
|
@ -35,6 +35,9 @@
|
|||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_NANOSLEEP
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#include "Foundation/NSThread.h"
|
||||
#include "Foundation/NSLock.h"
|
||||
|
@ -495,21 +498,24 @@ gnustep_base_thread_callback()
|
|||
while (delay > 30.0*60.0)
|
||||
{
|
||||
// sleep 30 minutes
|
||||
#ifdef HAVE_USLEEP
|
||||
usleep (30*60*1000000);
|
||||
#else
|
||||
#if defined(__MINGW__)
|
||||
Sleep (30*60*1000);
|
||||
#else
|
||||
sleep (30*60);
|
||||
#endif
|
||||
#endif
|
||||
delay = [date timeIntervalSinceNow];
|
||||
}
|
||||
|
||||
// usleep may return early because of signals
|
||||
// sleeping may return early because of signals
|
||||
while (delay > 0)
|
||||
{
|
||||
#ifdef HAVE_NANOSLEEP
|
||||
struct timespec req;
|
||||
|
||||
req.tv_sec = (time_t)delay;
|
||||
req.tv_nsec = (long)((delay - req.tv_sec) * 1000000000);
|
||||
nanosleep(&req, 0);
|
||||
#else
|
||||
#ifdef HAVE_USLEEP
|
||||
usleep ((int)(delay*1000000));
|
||||
#else
|
||||
|
@ -518,6 +524,7 @@ gnustep_base_thread_callback()
|
|||
#else
|
||||
sleep ((int)delay);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
delay = [date timeIntervalSinceNow];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue