Differences From Artifact [0d55db513d]:
- File
src/OFThreadPool.m
— part of check-in
[c5ef582958]
at
2013-03-04 17:20:15
on branch trunk
— Replace BOOL with bool.
The only places where BOOL is left are those where they are required by
the ABI. (user: js, size: 6988) [annotate] [blame] [check-ins using]
To Artifact [b54e691e3d]:
- File src/OFThreadPool.m — part of check-in [27138ee85b] at 2013-03-14 19:25:48 on branch trunk — Add a few memory barriers. (user: js, size: 7190) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
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 | [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)++; | > > > > > > | 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 242 | [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)++; |
︙ | ︙ | |||
304 305 306 307 308 309 310 311 312 313 314 315 316 317 | [_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]; | > > | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | [_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]; |
︙ | ︙ |