Differences From Artifact [26d1ba486e]:
- File
src/OFThreadPool.m
— part of check-in
[a3639589d3]
at
2013-06-30 18:30:12
on branch trunk
— Rename -[initWithBlock:].
It is now called -[initWithThreadBlock:] in order to prevent method
signature conflicts.This also fixes a missing release for the thread block. (user: js, size: 7167) [annotate] [blame] [check-ins using]
To Artifact [023cda67c9]:
- File
src/OFThreadPool.m
— part of check-in
[0fea69d149]
at
2013-07-04 13:59:28
on branch trunk
— 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. (user: js, size: 6965) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
169 170 171 172 173 174 175 | [super dealloc]; } - (id)main { void *pool; | < < < < < < | 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 | [_countCondition lock]; @try { OFEnumerator *enumerator = [_threads objectEnumerator]; OFThreadPoolThread *thread; while ((thread = [enumerator nextObject]) != nil) thread->_terminate = true; | < < | 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]; |
︙ | ︙ |