ObjFW  Check-in [49ec1216cd]

Overview
Comment:More precision for microseconds.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 49ec1216cd8fabd6baaaed962481c948017ed55e4761c87bbedbc0c5f348a6a5
User & Date: js on 2011-09-21 20:11:38
Other Links: manifest | tags
Context
2011-09-22
01:11
Add support for kqueue. check-in: 4f6270da38 user: js tags: trunk
2011-09-21
20:11
More precision for microseconds. check-in: 49ec1216cd user: js tags: trunk
2011-09-20
21:57
Fix conflicting declarations in tests. check-in: 5e214166e1 user: js tags: trunk
Changes

Modified src/OFDate.m from [127168a624] to [715fe07d58].

371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
	[element autorelease];

	return element;
}

- (uint32_t)microsecond
{
	return (uint32_t)fmod(seconds * 1000000, 1000000);
}

- (uint8_t)second
{
	GMTIME_RET(tm_sec)
}








|







371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
	[element autorelease];

	return element;
}

- (uint32_t)microsecond
{
	return (uint32_t)nearbyint((seconds - floor(seconds)) * 1000000);
}

- (uint8_t)second
{
	GMTIME_RET(tm_sec)
}

Modified src/OFThread.m from [e46284151e] to [9734ed9f86].

164
165
166
167
168
169
170
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
		@throw [OFOutOfRangeException newWithClass: self];

#ifndef _WIN32
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	sleep((unsigned int)seconds);
	usleep((useconds_t)fmod(seconds * 1000000, 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

	Sleep((unsigned int)(seconds * 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((useconds_t)fmod(seconds * 1000000, 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

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







|

















|







164
165
166
167
168
169
170
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
		@throw [OFOutOfRangeException newWithClass: self];

#ifndef _WIN32
	if (seconds > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

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

	Sleep((unsigned int)(seconds * 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((useconds_t)nearbyint((seconds - floor(seconds)) * 1000000));
#else
	if (seconds * 1000 > UINT_MAX)
		@throw [OFOutOfRangeException newWithClass: self];

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