14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
* file.
*/
#include "config.h"
#define __NO_EXT_QNX
#ifndef _WIN32
# include <unistd.h>
# include <sched.h>
#else
# include <windows.h>
#endif
|
>
>
|
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
* file.
*/
#include "config.h"
#define __NO_EXT_QNX
#include <math.h>
#ifndef _WIN32
# include <unistd.h>
# include <sched.h>
#else
# include <windows.h>
#endif
|
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
Sleep((unsigned int)seconds * 1000 + microseconds / 1000);
#endif
}
+ (void)sleepUntilDate: (OFDate*)date
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFDate *now = [OFDate date];
int64_t seconds;
uint32_t microseconds;
if ((seconds = [date timeIntervalSinceDate: now]) < 0)
@throw [OFOutOfRangeException newWithClass: self];
microseconds = [date microsecondsOfTimeIntervalSinceDate: now];
[pool release];
#ifndef _WIN32
if (seconds > UINT_MAX)
@throw [OFOutOfRangeException newWithClass: self];
sleep((unsigned int)seconds);
usleep(microseconds);
#else
if (seconds * 1000 + microseconds / 1000 > UINT_MAX)
@throw [OFOutOfRangeException newWithClass: self];
Sleep(seconds * 1000 + microseconds / 1000);
#endif
}
+ (void)yield
{
#ifdef OF_HAVE_SCHED_YIELD
sched_yield();
|
<
<
<
<
<
|
<
<
<
<
<
|
|
|
|
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
Sleep((unsigned int)seconds * 1000 + microseconds / 1000);
#endif
}
+ (void)sleepUntilDate: (OFDate*)date
{
double seconds = [date timeIntervalSinceNow];
#ifndef _WIN32
if (seconds > UINT_MAX)
@throw [OFOutOfRangeException newWithClass: self];
sleep((unsigned int)seconds);
usleep(nearbyint(remainder(seconds, 1) * 1000000));
#else
if (seconds * 1000 > UINT_MAX)
@throw [OFOutOfRangeException newWithClass: self];
Sleep(seconds * 1000);
#endif
}
+ (void)yield
{
#ifdef OF_HAVE_SCHED_YIELD
sched_yield();
|