ObjFW  Diff

Differences From Artifact [b35e0e98a2]:

To Artifact [b5e162fd36]:


171
172
173
174
175
176
177





178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#endif

+ (void)sleepForTimeInterval: (double)seconds
{
	if (seconds < 0)
		@throw [OFOutOfRangeException exception];






#if defined(HAVE_NANOSLEEP)
	struct timespec rqtp;

	rqtp.tv_sec = (time_t)seconds;
	rqtp.tv_nsec = lrint((seconds - rqtp.tv_sec) * 1000000000);

	if (rqtp.tv_sec != floor(seconds))
		@throw [OFOutOfRangeException exception];

	nanosleep(&rqtp, NULL);
#elif !defined(_WIN32)
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	sleep((unsigned int)seconds);
	usleep((useconds_t)lrint((seconds - floor(seconds)) * 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	Sleep((unsigned int)(seconds * 1000));
#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
	[self sleepForTimeInterval: [date timeIntervalSinceNow]];
}







>
>
>
>
>
|









|





<
<
<
<
<







171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198





199
200
201
202
203
204
205
#endif

+ (void)sleepForTimeInterval: (double)seconds
{
	if (seconds < 0)
		@throw [OFOutOfRangeException exception];

#if defined(_WIN32)
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	Sleep((unsigned int)(seconds * 1000));
#elif defined(HAVE_NANOSLEEP)
	struct timespec rqtp;

	rqtp.tv_sec = (time_t)seconds;
	rqtp.tv_nsec = lrint((seconds - rqtp.tv_sec) * 1000000000);

	if (rqtp.tv_sec != floor(seconds))
		@throw [OFOutOfRangeException exception];

	nanosleep(&rqtp, NULL);
#else
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException exception];

	sleep((unsigned int)seconds);
	usleep((useconds_t)lrint((seconds - floor(seconds)) * 1000000));





#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
	[self sleepForTimeInterval: [date timeIntervalSinceNow]];
}