Pro Yearly is on sale from $80 to $50! »

Concurrency From the Ground Up

06609d73ad2165c4aafcf65a1ddb9563?s=47 Greg Heo
August 27, 2018

Concurrency From the Ground Up

What are the fundamental building blocks of concurrency underneath the APIs we use every day?

Presented at 360iDev 2018.

06609d73ad2165c4aafcf65a1ddb9563?s=128

Greg Heo

August 27, 2018
Tweet

Transcript

  1. Concurrency
 From the
 Ground Up @gregheo 360iDev 2018 {

  2. @gregheo 360iDev 2018 Concurrency

  3. @gregheo 360iDev 2018 1. Programs that seem faster to the

    user 2. Programs that are easy to understand for the programmer WHY? WHY?
  4. @gregheo 360iDev 2018 1. Structuring our programs better 2. Thinking

    in terms of Tasks 3. Protecting Resources
  5. @gregheo 360iDev 2018 mainQueue.async { } troublesomeCode()

  6. @gregheo 360iDev 2018 mainQueue.asyncAfter(.now + 0.1) { } troublesomeCode()

  7. @gregheo 360iDev 2018 Concurrency
 &
 Structure

  8. @gregheo 360iDev 2018 Concurrency
 Parallelism

  9. @gregheo 360iDev 2018 “concurrency is the composition of independently executing

    processes”
  10. @gregheo 360iDev 2018 “parallelism is the simultaneous execution of (possibly

    related) computations”
  11. @gregheo 360iDev 2018 “parallelism is the simultaneous execution of computations”

  12. @gregheo 360iDev 2018 “
 
 Parallelism is about doing lots

    of things at once.” Concurrency is about dealing with lots of things at once.
  13. @gregheo 360iDev 2018

  14. @gregheo 360iDev 2018

  15. @gregheo 360iDev 2018

  16. @gregheo 360iDev 2018 C B A A()
 B()
 C()

  17. @gregheo 360iDev 2018 A B C

  18. @gregheo 360iDev 2018 A B C

  19. @gregheo 360iDev 2018 A B C data

  20. @gregheo 360iDev 2018 Order? Shared state? Mutable state?

  21. @gregheo 360iDev 2018 Tasks
 &
 Threads

  22. @gregheo 360iDev 2018 thread function thread thread

  23. @gregheo 360iDev 2018 pthread GCD queue NSOperation dispatch groups

  24. @gregheo 360iDev 2018 Locks
 &
 Resources

  25. @gregheo 360iDev 2018 Lock • Locks as signals • Locks

    as mutual exclusion
  26. @gregheo 360iDev 2018 pthread mutex semaphore os_unfair_lock NSLock GCD
 semaphore

    dispatch
 groups
  27. @gregheo 360iDev 2018 1. Structuring our programs better 2. Thinking

    in terms of Tasks 3. Protecting Resources
  28. @gregheo 360iDev 2018 1. Programs that seem faster to the

    user 2. Programs that are easy to understand for the programmer
  29. @gregheo 360iDev 2018 pthread GCD
 queue Groups pthread
 mutex unfair

    lock NSLock GCD
 semaphore pthread
 semaphore NSThread }