Thread safety #18

Merged
merged 3 commits into from Aug 31, 2011

Projects

None yet

4 participants

@evanlong
Contributor

Making AFImageCache lazy init thread safe since it is called from main thread and background threads. Also making the increment and decrement for AFNetworkActivityIndicatorManager thread safe since start/stopAnimating are called from different threads.

Also change the example project to reference libz.dylib instead of the specific version of libz1.x.x. This should make the example more future proof and also makes it work for Xcode 3.2.6 and Snow Leopard.

@evanlong evanlong Making AFImageCache lazy init thread safe since it is called from mai…
…n thread and background threads. Also making the increment and decrement for AFNetworkActivityIndicatorManager thread safe since start/stopAnimating are called from different threads.
dddd567
@sco
Contributor
sco commented Aug 31, 2011

+1

@soffes
Contributor
soffes commented Aug 31, 2011

Good work @evanlong :)

Evan Long Need the reads on the property to be atomic as well. Otherwise there …
…as cases like 'startAnimating' getting called from two seperate threads. Each would read a value A. The first thread would then write the value A+1. Thread 2 also read A so it would also write A+1. As a result missing an increment
9a0ed24
@evanlong
Contributor

Yay threading. Ya the increments on activity indicator should be safe now

@evanlong
Contributor

So before the read and write were atomic I meant to make the increment and decrement atomic.

@mattt mattt merged commit d8e0784 into AFNetworking:master Aug 31, 2011
@mattt
Contributor
mattt commented Aug 31, 2011

Well done, Evan. Thanks for the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment