ObjFW  Check-in [98b8d76bbc]

Overview
Comment:Add +[sleepForNMilliseconds:] to OFThread.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 98b8d76bbce336d9654a5bfa7a8bdf922e45484e884cda31342c89d97581ee91
User & Date: js on 2010-04-10 22:00:33
Other Links: manifest | tags
Context
2010-04-10
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
21:49
Retain the thread in -[start] first to prevent a race condition. check-in: 82fe4443e2 user: js tags: trunk
Changes

Modified src/OFThread.h from [413f614157] to [d4b4d3301a].

97
98
99
100
101
102
103





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







+
+
+
+
+







+ (id)objectForTLSKey: (OFTLSKey*)key;

/**
 * \return The current thread or nil if we are in the main thread
 */
+ (OFThread*)currentThread;

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

/**
 * 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 [e7e5a215e2] to [e58214a2fc].

1
2
3
4
5
6
7
8
9
10
11
12






13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25












+
+
+
+
+
+







/*
 * Copyright (c) 2008 - 2010
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

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

#import "OFThread.h"
#import "OFList.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"

#import "threading.h"
80
81
82
83
84
85
86









87
88
89
90
91
92
93
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108







+
+
+
+
+
+
+
+
+







	return [[of_tlskey_get(key->key) retain] autorelease];
}

+ (OFThread*)currentThread
{
	return of_tlskey_get(thread_self);
}

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

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

+ (void)terminateWithObject: (id)obj