> On Apr 26, 2017, at 10:51 AM, Shawn Erickson <[email protected]> wrote:
> 
> Anyway, most of the time, to be properly safe you need to share a single 
> lock/spinlock/semaphore/dispatch queue/something between your properties, not 
> give each one their own.
> 
> Exactly! Atomic properties – in my experience – usually are too fine-grained 
> for real world code. They can work well for a subset of needs but most of the 
> time you need less granular locking to incorporate dependent logic inside of 
> the critical section, etc.

Again, +1 / Amen brothers / Couldn’t agree more.

Making the implementation of an interface thread-safe does _not_ necessarily 
make using the interface thread-safe. That’s a hard lesson to learn; it took me 
a while. The mistake seems to be made pretty often: for example, early Java 
code assumed you could simply slap “synchronized” on all your public methods 
and call it a day.

In the [C++] code I’m currently writing, I’ve switched to the Actor pattern, 
and I really like it. Class implementations are single-threaded, so no worries 
about locking; but messaging between objects is asynchronous (with callbacks 
instead of return values.)

—Jens
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to