NSConditionLock vs. plain variable question...
NSConditionLock vs. plain variable question...
- Subject: NSConditionLock vs. plain variable question...
- From: "Juan P. Pertierra" <email@hidden>
- Date: Tue, 9 May 2006 21:01:48 -0400
Hello,
My Cocoa application has a background thread which contains an async
callback function which gets periodically called by the system.
At one point, my main thread wants to change the value of a single
variable which is used in the callback, so I want to make sure a
callback is not in progress before changing it.
I'd like to keep the callback as simple as possible. Is there any
reason not to use just a simple global variable "inCallback", set it
to "1" at the beginning at the callback and set it to "0" at the end
of the callback, then just check it in the main thread? i.e. if
"inCallback == 1" then wait to change the variable, until "inCallback
== 0". It seems like NSConditionLock/NSLock will have more overhead
than just changing the value of a variable, but I'm probably wrong.
Thanks,
Juan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden