ObjFW  Check-in [2fb2ff521f]

Overview
Comment:Some systems don't allow usleep for values > 1000000.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2fb2ff521f08c51b83841f33b38b9a5c9aa1d62e11c176a3fae37654045953eb
User & Date: js on 2011-01-11 21:56:54
Other Links: manifest | tags
Context
2011-01-11
22:03
Replace -[sleepForNMilliseconds:] with -[sleepForTimeInterval:]. check-in: 219a630ef0 user: js tags: trunk
21:56
Some systems don't allow usleep for values > 1000000. check-in: 2fb2ff521f user: js tags: trunk
21:56
Fix a very stupid typo in -[OFDate timeIntervalSinceDate:]. check-in: 77e8aff469 user: js tags: trunk
Changes

Modified src/OFThread.m from [8e9159db32] to [ea45b83ab4].

95
96
97
98
99
100
101
102

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

123
124
125
126
127
128
129
130
{
	return of_tlskey_get(thread_self);
}

+ (void)sleepForNMilliseconds: (unsigned int)msecs;
{
#ifndef _WIN32
	usleep(msecs * 1000);

#else
	Sleep(msecs);
#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFDate *now = [OFDate date];
	int64_t sec;
	uint32_t usec;

	if ((sec = [date timeIntervalSinceDate: now]) < 0)
		@throw [OFOutOfRangeException newWithClass: self];

	usec = [date microsecondsOfTimeIntervalSinceDate: now];

	[pool release];

#ifndef _WIN32

	usleep(sec * 1000000 + usec);
#else
	Sleep(sec * 1000 + usec / 1000);
#endif
}

+ (void)yield
{







|
>




















>
|







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{
	return of_tlskey_get(thread_self);
}

+ (void)sleepForNMilliseconds: (unsigned int)msecs;
{
#ifndef _WIN32
	sleep(msecs / 1000);
	usleep((msecs % 1000) * 1000);
#else
	Sleep(msecs);
#endif
}

+ (void)sleepUntilDate: (OFDate*)date
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFDate *now = [OFDate date];
	int64_t sec;
	uint32_t usec;

	if ((sec = [date timeIntervalSinceDate: now]) < 0)
		@throw [OFOutOfRangeException newWithClass: self];

	usec = [date microsecondsOfTimeIntervalSinceDate: now];

	[pool release];

#ifndef _WIN32
	sleep(sec);
	usleep(usec);
#else
	Sleep(sec * 1000 + usec / 1000);
#endif
}

+ (void)yield
{