Re: AVFoundation and the main thread
Re: AVFoundation and the main thread
- Subject: Re: AVFoundation and the main thread
- From: Jens Alfke <email@hidden>
- Date: Tue, 20 Dec 2016 09:09:46 -0800
I’ll also argue that if you’re needing to do this kind of thing from a background thread, your code isn’t factored properly.
Managing the UI of the app is far too complex a task to try to coordinate among multiple threads. The current best practices for concurrent programming suggest that you should try to minimize the amount of (mutable) state shared between threads, and instead have the threads interact mostly by messaging.
So in this specific case, if a background thread does something that requires a player view to be resized, it should send a message (or post a block) to the main thread and let the main thread do it. (And hopefully the background thread isn’t concerning itself with pixels, but instead with something like the length of a track or the number of tracks, which the main thread’s UI logic can then translate into pixel dimensions.)
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden