On 15 Mar 2009, at 15:43, Joar Wingfors <j...@joar.com> wrote:

On 15 mar 2009, at 01.14, Paul Sanders wrote:

I was referring to where the OP said:

"but would it be safe, given the fact that sum and count are bound
to some textFields / progressIndicator"

And presumably it would not be as the instance variables referred to
were being mutated in a secondary thread.


That's right. If you've established bindings to some property of an
object, it's no longer OK to update that property from background
threads.

Please refer to the Cocoa thread safety documentations:

<http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/Introduction/Introduction.html

Could you please point to the exact section where it is stated that it is not OK to update a bound property from a background thread?


If main is an instance of the Main class, which has:

- (void)add2Number: (int)i
{
        OSAtomicAdd32 (i, &tempSum);

        if ( more than 0.1 seconds have passed )
[ self performSelectorOnMainThread:@selector(reallySum) withObject:nil waitUntilDone:NO];
}

- (void)reallySum
{
        self.sum = tempSum;
}

The property "sum" is bound to the "value" of some NSTextField.

Is is ok to send [ main add2Number: someNumber ] from another thread?


Kind regards,

Gerriet.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to