I'm reading Core Animation Programming Guide and in the chapter of "Transactions", I see this
Important: When modifying layer properties from threads that don’t have a runloop, you must use explicit transactions.
but From Apple's documentation on NSRunLoop
Your application cannot either create or explicitly manage NSRunLoop objects. Each NSThread object, including the application’s main thread, has an NSRunLoop object automatically created for it as needed.
Doesn't it mean every thread has a runloop? or threads that's not created by NSThread, such as POSIX's pthread
It says “Each NSThread
object, including the application’s main thread, has an NSRunLoop
object automatically created for it as needed.”
If you don't do anything that tries to access a thread's run loop, the system won't create a run loop for the thread.
If you don't do [[NSRunLoop currentRunLoop] run]
(or something equivalent), your thread won't run its run loop.
The UIApplicationMain
function takes care of this for the main thread. For threads you create, you need to run the thread's run loop if you want the thread's run loop to have any effect.
Here's what's happening (I think) in the case of Core Animation, when you don't use an explicit transaction. It begins a transaction, and registers a callback with the current thread's run loop to commit it. (This will create a run loop for the current thread if necessary.) If you're not running the thread's run loop, that callback will never be called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With