ObjFW  Check-in [0fea69d149]

Overview
Comment:Remove useless barriers.

We don't care about the order here, we only care about getting the
update. The barrier is only useful to force the order.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0fea69d149c1f653c54057ee2a4c64d5bd8de17fac52468b7bbb60006b3049ff
User & Date: js on 2013-07-04 13:59:28
Other Links: manifest | tags
Context
2013-07-04
14:04
OFBlock: Initialize spinlocks in +[load]. check-in: 8fbc6b4e63 user: js tags: trunk
13:59
Remove useless barriers. check-in: 0fea69d149 user: js tags: trunk
2013-07-03
21:29
Check all -W flags with -Werror. check-in: c23578f03f user: js tags: trunk
Changes

Modified src/OFRunLoop.m from [410ce014df] to [3252e51e8a].

622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638

	for (;;) {
		void *pool;
		OFDate *now;
		OFTimer *timer;
		OFDate *nextTimer;

#ifdef OF_HAVE_THREADS
		of_memory_read_barrier();
#endif
		if (!_running)
			break;

		pool = objc_autoreleasePoolPush();
		now = [OFDate date];

#ifdef OF_HAVE_THREADS







<
<
<







622
623
624
625
626
627
628



629
630
631
632
633
634
635

	for (;;) {
		void *pool;
		OFDate *now;
		OFTimer *timer;
		OFDate *nextTimer;




		if (!_running)
			break;

		pool = objc_autoreleasePoolPush();
		now = [OFDate date];

#ifdef OF_HAVE_THREADS
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
		objc_autoreleasePoolPop(pool);
	}
}

- (void)stop
{
	_running = false;
#ifdef OF_HAVE_THREADS
	of_memory_write_barrier();
#endif
#if defined(OF_HAVE_SOCKETS)
	[_streamObserver cancel];
#elif defined(OF_HAVE_THREADS)
	[_condition lock];
	[_condition signal];
	[_condition unlock];
#endif
}
@end







<
<
<









706
707
708
709
710
711
712



713
714
715
716
717
718
719
720
721
		objc_autoreleasePoolPop(pool);
	}
}

- (void)stop
{
	_running = false;



#if defined(OF_HAVE_SOCKETS)
	[_streamObserver cancel];
#elif defined(OF_HAVE_THREADS)
	[_condition lock];
	[_condition signal];
	[_condition unlock];
#endif
}
@end

Modified src/OFThreadPool.m from [26d1ba486e] to [023cda67c9].

169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
	[super dealloc];
}

- (id)main
{
	void *pool;

	of_memory_read_barrier();
	if (_terminate)
		return nil;

	pool = objc_autoreleasePoolPush();

	for (;;) {
		OFThreadPoolJob *job;

		[_queueCondition lock];
		@try {
			of_list_object_t *listObject;

			of_memory_read_barrier();
			if (_terminate) {
				objc_autoreleasePoolPop(pool);
				return nil;
			}

			listObject = [_queue firstListObject];

			while (listObject == NULL) {
				[_queueCondition wait];

				of_memory_read_barrier();
				if (_terminate) {
					objc_autoreleasePoolPop(pool);
					return nil;
				}

				listObject = [_queue firstListObject];
			}

			job = [[listObject->object retain] autorelease];
			[_queue removeListObject: listObject];
		} @finally {
			[_queueCondition unlock];
		}

		of_memory_read_barrier();
		if (_terminate) {
			objc_autoreleasePoolPop(pool);
			return nil;
		}

		[job perform];

		of_memory_read_barrier();
		if (_terminate) {
			objc_autoreleasePoolPop(pool);
			return nil;
		}

		objc_autoreleasePoolPop(pool);
		pool = objc_autoreleasePoolPush();

		[_countCondition lock];
		@try {
			of_memory_read_barrier();
			if (_terminate) {
				objc_autoreleasePoolPop(pool);
				return nil;
			}

			(*_doneCount)++;








<












<










<














<







<










<







169
170
171
172
173
174
175

176
177
178
179
180
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195
196
197

198
199
200
201
202
203
204
205
206
207
208
209
210
211

212
213
214
215
216
217
218

219
220
221
222
223
224
225
226
227
228

229
230
231
232
233
234
235
	[super dealloc];
}

- (id)main
{
	void *pool;


	if (_terminate)
		return nil;

	pool = objc_autoreleasePoolPush();

	for (;;) {
		OFThreadPoolJob *job;

		[_queueCondition lock];
		@try {
			of_list_object_t *listObject;


			if (_terminate) {
				objc_autoreleasePoolPop(pool);
				return nil;
			}

			listObject = [_queue firstListObject];

			while (listObject == NULL) {
				[_queueCondition wait];


				if (_terminate) {
					objc_autoreleasePoolPop(pool);
					return nil;
				}

				listObject = [_queue firstListObject];
			}

			job = [[listObject->object retain] autorelease];
			[_queue removeListObject: listObject];
		} @finally {
			[_queueCondition unlock];
		}


		if (_terminate) {
			objc_autoreleasePoolPop(pool);
			return nil;
		}

		[job perform];


		if (_terminate) {
			objc_autoreleasePoolPop(pool);
			return nil;
		}

		objc_autoreleasePoolPop(pool);
		pool = objc_autoreleasePoolPush();

		[_countCondition lock];
		@try {

			if (_terminate) {
				objc_autoreleasePoolPop(pool);
				return nil;
			}

			(*_doneCount)++;

309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
		[_countCondition lock];
		@try {
			OFEnumerator *enumerator = [_threads objectEnumerator];
			OFThreadPoolThread *thread;

			while ((thread = [enumerator nextObject]) != nil)
				thread->_terminate = true;

			of_memory_write_barrier();
		} @finally {
			[_countCondition unlock];
		}

		[_queueCondition broadcast];
	} @finally {
		[_queueCondition unlock];







<
<







303
304
305
306
307
308
309


310
311
312
313
314
315
316
		[_countCondition lock];
		@try {
			OFEnumerator *enumerator = [_threads objectEnumerator];
			OFThreadPoolThread *thread;

			while ((thread = [enumerator nextObject]) != nil)
				thread->_terminate = true;


		} @finally {
			[_countCondition unlock];
		}

		[_queueCondition broadcast];
	} @finally {
		[_queueCondition unlock];