OSX Objective C BOOL/vars thread safe? -
Simple question ... What is a global BOOL thread safe for me to use for thread synchronization? Other data types are actually safe, e.g. Long long ..?
Example: I have a task that runs - only once to run it together.
& lt; Pre & gt; BOOL is isunning; Unsigned long-term progress; If (IsRunning) {dispatch_async (secondary task, ^ {{self-declarer}}}; - (zero) doWork {isRunning = TRUE; Have a long session = Running; } & Lt; / Pre & gt; For the nuclear type, the same rules apply equally to the normal C.
So there is no guarantee of thread protection on any of them.
OSAtomic, NSConditionLock
, NSLocking
Protocol, Serial Remote Queue, Personal Runlops, Use Memory Fence to Get Thread Security, Spin Lock, e.t.c.
For the trivial code given, which I accept is probably for Exposure, you will provide the most complete handler block, which will be asynchronous block sending upon completion if it is a serial queue , Then just press the job for it. Consider a remittance group if you want synchronization points within the synchronous working groups.
Comments
Post a Comment