Get introduced to Apple recommendations on avoiding deadlocks by using dispatch_async. You should know what brings about deadlocks and best practices for avoiding deadlocks
- [Instructor] There isn't one right answer … to avoiding deadlocks, … but since the introduction of Grand Central Dispatch, … using threads is safer because it's handled by the system. … But there are some techniques you can use … to avoid deadlocks, such as moving some tasks … from the main thread. … Another remedy is not calling the dispatch.sync function … from a task that is executing on the same queue … that you pass to your function call. … Doing so will deadlock the queue. … If you need to dispatch to the current queue, … do so asynchronously using the dispatch.async function. … You can also use NSRecursiveLocks to avoid deadlocks. … NSRecursiveLock is a lock … that can be acquired multiple times by the same thread … without causing a deadlock. … The locks and unlocks have to be balanced. … When there's a balance between the locks and unlocks, … the lock is released for other threads to acquire it. … Another option will be to use a Scheduler provided … in the Combine Framework. …
Skill Level Intermediate
1. Evolution of GCD
2. Working with Queues
3. Asychronous vs. Synchronous Execution
4. Concurrency vs. Parallelism
What are deadlocks?1m 21s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.