ObjFW  Diff

Differences From Artifact [3a80ac4df5]:

To Artifact [629df82865]:


256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271

272
273
274
275
276
277
278
279
280
281
282
283
284

285
286

287
288
289
290
291
292
293
256
257
258
259
260
261
262


263
264
265
266
267
268

269
270
271
272
273
274
275
276
277
278
279
280
281

282
283

284
285
286
287
288
289
290
291







-
-






-
+












-
+

-
+







}

- initWithSize: (size_t)size
{
	self = [super init];

	@try {
		size_t i;

		_size = size;
		_threads = [[OFMutableArray alloc] init];
		_queue = [[OFList alloc] init];
		_queueCondition = [[OFCondition alloc] init];
		_countCondition = [[OFCondition alloc] init];

		for (i = 0; i < size; i++) {
		for (size_t i = 0; i < size; i++) {
			void *pool = objc_autoreleasePoolPush();

			OFThreadPoolThread *thread =
			    [OFThreadPoolThread threadWithThreadPool: self];

			[_threads addObject: thread];

			objc_autoreleasePoolPop(pool);
		}

		/*
		 * We need to start the threads in a separate loop to make sure
		 * threads is not modified anymore to prevent a race condition.
		 * _threads is not modified anymore to prevent a race condition.
		 */
		for (i = 0; i < size; i++)
		for (size_t i = 0; i < size; i++)
			[[_threads objectAtIndex: i] start];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;