ObjFW  Check-in [cf8db6867d]

Overview
Comment:OFThread: Make the block the last argument.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cf8db6867de8c6a4dd364a05e6cf19fae57ef4c8a55e4e3895871da663bab47f
User & Date: js on 2012-09-15 12:21:09
Other Links: manifest | tags
Context
2012-09-15
12:22
OFTCPSocket: Implement async connecting. check-in: 3b68656e8d user: js tags: trunk
12:21
OFThread: Make the block the last argument. check-in: cf8db6867d user: js tags: trunk
12:20
OFThread: Implement the OFCopying protocol. check-in: 2929f89f3e user: js tags: trunk
Changes

Modified src/OFThread.h from [c69b3187df] to [053c62f685].

135
136
137
138
139
140
141
142
143

144
145

146

147
148
149
150
151
152
153
154
135
136
137
138
139
140
141

142
143
144
145
146

147

148
149
150
151
152
153
154







-

+


+
-
+
-







 * \return A new, autoreleased thread
 */
+ threadWithBlock: (of_thread_block_t)block;

/**
 * \brief Creates a new thread with the specified block and object.
 *
 * \param block A block which is executed by the thread
 * \param object An object which is passed for use in the main method or nil
 * \param block A block which is executed by the thread
 * \return A new, autoreleased thread
 */
+ threadWithObject: (id)object
+ threadWithBlock: (of_thread_block_t)block
	     block: (of_thread_block_t)block;
	   object: (id)object;
#endif

/**
 * \brief Sets the Thread Local Storage for the specified key.
 *
 * The specified object is first retained and then the object stored before is
 * released. You can specify nil as object if you want the old object to be
240
241
242
243
244
245
246

247

248
249
250
251
252
253
254
255
240
241
242
243
244
245
246
247

248

249
250
251
252
253
254
255







+
-
+
-







 * \brief Initializes an already allocated thread with the specified block and
 *	  object.
 *
 * \param block A block which is executed by the thread
 * \param object An object which is passed for use in the main method or nil
 * \return An initialized OFThread.
 */
- initWithObject: (id)object
- initWithBlock: (of_thread_block_t)block
	   block: (of_thread_block_t)block;
	 object: (id)object;
#endif

/**
 * \brief The main routine of the thread. You need to reimplement this!
 *
 * It can access the object passed to the threadWithObject or initWithObject
 * method using the instance variable named object.

Modified src/OFThread.m from [eea4c563b1] to [dc21f4b704].

119
120
121
122
123
124
125

126

127
128
129
130


131
132
133
134
135
136
137
119
120
121
122
123
124
125
126

127

128


129
130
131
132
133
134
135
136
137







+
-
+
-

-
-
+
+








#ifdef OF_HAVE_BLOCKS
+ threadWithBlock: (of_thread_block_t)block
{
	return [[[self alloc] initWithBlock: block] autorelease];
}

+ threadWithObject: (id)object
+ threadWithBlock: (of_thread_block_t)block
	     block: (of_thread_block_t)block
	   object: (id)object
{
	return [[[self alloc] initWithBlock: block
				     object: object] autorelease];
	return [[[self alloc] initWithObject: object
				       block: block] autorelease];
}
#endif

+ (void)setObject: (id)object
	forTLSKey: (OFTLSKey*)key
{
	id oldObject = of_tlskey_get(key->key);
247
248
249
250
251
252
253
254
255


256
257

258

259
260
261
262
263
264
265

266
267
268
269
270
271
272
247
248
249
250
251
252
253


254
255
256
257
258

259

260
261
262
263

264
265
266
267
268
269
270
271
272







-
-
+
+


+
-
+
-




-

+








	return self;
}

#ifdef OF_HAVE_BLOCKS
- initWithBlock: (of_thread_block_t)block_
{
	return [self initWithBlock: block_
			    object: nil];
	return [self initWithObject: nil
			      block: block_];
}

- initWithObject: (id)object_
- initWithBlock: (of_thread_block_t)block_
	   block: (of_thread_block_t)block_
	 object: (id)object_
{
	self = [super init];

	@try {
		block = [block_ copy];
		object = [object_ retain];
		block = [block_ copy];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}