ObjFW  Check-in [1adf3bb9bf]

Overview
Comment:Add +[yield] to OFThread.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1adf3bb9bfd74cfd4dba87d30247efda7113c843e336bf5721bf1874656c1a45
User & Date: js on 2010-04-10 22:06:01
Other Links: manifest | tags
Context
2010-04-10
22:33
There was no real reason to rename -[main] to -[run]. Undo it. check-in: 663f63e55a user: js tags: trunk
22:06
Add +[yield] to OFThread. check-in: 1adf3bb9bf user: js tags: trunk
22:00
Add +[sleepForNMilliseconds:] to OFThread. check-in: 98b8d76bbc user: js tags: trunk
Changes

Modified src/OFThread.h from [d4b4d3301a] to [ca016b6bde].

102
103
104
105
106
107
108






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







+
+
+
+
+
+







+ (OFThread*)currentThread;

/**
 * Suspends execution of the current thread for N milliseconds.
 */
+ (void)sleepForNMilliseconds: (unsigned int)msecs;

/**
 * Yields a processor voluntarily and moves the thread at the end of the queue
 * for its priority.
 */
+ (void)yield;

/**
 * Terminates the current thread, letting it return nil.
 */
+ (void)terminate;

/**
 * Terminates the current thread, letting it return the specified object.

Modified src/OFThread.m from [e58214a2fc] to [6abaf9455e].

9
10
11
12
13
14
15

16
17
18
19
20
21
22
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23







+







 * the packaging of this file.
 */

#include "config.h"

#ifndef _WIN32
# include <unistd.h>
# include <sched.h>
#else
# include <windows.h>
#endif

#import "OFThread.h"
#import "OFList.h"
#import "OFAutoreleasePool.h"
95
96
97
98
99
100
101









102
103
104
105
106
107
108
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118







+
+
+
+
+
+
+
+
+







{
#ifndef _WIN32
	usleep(msecs * 1000);
#else
	Sleep(msecs);
#endif
}

+ (void)yield
{
#ifndef _WIN32
	sched_yield();
#else
	Sleep(0);
#endif
}

+ (void)terminate
{
	[self terminateWithObject: nil];
}

+ (void)terminateWithObject: (id)obj