FROM : Cem Karan
DATE : Thu Aug 10 17:27:40 2006
> 1. Start a periodic timer in your main thread and use a shared
> variable to store progress information. You protect your shared
> variables using @synchronized or NSLock objects if necessary (if it's
> just a 32 bit integer storing progress that's not necessary).
Please use locks or @synchronized on everything that's shared, unless
you are utterly certain that there is no way that corruption of the
shared data can ever affect you. I've seen some very, very strange
problems happen because someone decided that not locking was OK 'just
this once' which can be easily avoided by locking/synchronizing.
And before you say that it's OK because it is just a 32 bit integer,
yes, I HAVE seen weirdness that way too; I'll admit, it was on a
misaligned data access (part of a packed struct), but still, it CAN
bite you!
Thanks,
Cem Karan
DATE : Thu Aug 10 17:27:40 2006
> 1. Start a periodic timer in your main thread and use a shared
> variable to store progress information. You protect your shared
> variables using @synchronized or NSLock objects if necessary (if it's
> just a 32 bit integer storing progress that's not necessary).
Please use locks or @synchronized on everything that's shared, unless
you are utterly certain that there is no way that corruption of the
shared data can ever affect you. I've seen some very, very strange
problems happen because someone decided that not locking was OK 'just
this once' which can be easily avoided by locking/synchronizing.
And before you say that it's OK because it is just a 32 bit integer,
yes, I HAVE seen weirdness that way too; I'll admit, it was on a
misaligned data access (part of a packed struct), but still, it CAN
bite you!
Thanks,
Cem Karan
| Related mails | Author | Date |
|---|---|---|
| Cem Karan | Aug 10, 17:27 | |
| John Stiles | Aug 10, 17:36 | |
| Cem Karan | Aug 10, 17:56 | |
| AgentM | Aug 10, 19:57 | |
| marc@mac.com | Aug 23, 16:59 | |
| Shawn Erickson | Aug 23, 17:29 | |
| Michael Ash | Aug 23, 17:47 | |
| Chris Suter | Aug 24, 02:01 |






Cocoa mail archive

