ObjFW  Diff

Differences From Artifact [4151197f7a]:

To Artifact [bbc593cb97]:


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
206
207
208
209
210
	if (thread->_threadDictionary == nil)
		thread->_threadDictionary = [[OFMutableDictionary alloc] init];

	return thread->_threadDictionary;
}
#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]];
}







|

|



|


|



|
|

|




|


|
|
>







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
206
207
208
209
210
211
	if (thread->_threadDictionary == nil)
		thread->_threadDictionary = [[OFMutableDictionary alloc] init];

	return thread->_threadDictionary;
}
#endif

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

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

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

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

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

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

	sleep((unsigned int)timeInterval);
	usleep((useconds_t)lrint(
	    (timeInterval - floor(timeInterval)) * 1000000));
#endif
}

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