Skip to content

Latest commit

 

History

History
32 lines (27 loc) · 1.95 KB

README.md

File metadata and controls

32 lines (27 loc) · 1.95 KB

Concurrency101

Gio + Iván holiday special: Concurrency

Playground Pages:

  • Sync vs Async
  • Serial vs Concurrent
  • DispatchGroup
  • DispatchQueue
  • Thread-Safe Data Structure
  • OperationQueue
  • Semaphore
  • Deadlock

Resources:

General Advice:

  • Avoid using concurrent queues at all cost.
    • Instead use a serial queue per sub system and use a target queue if you need subsystems to interact.
    • Reader/writer locks tend to be a source of great complexity and hard to get right, specially in Swift which is bad at atomic access. If needed it’s better to use os_unfair_lock
  • Combine helps handling concurrency with its stream of events API.
  • Don’t use GlobalQueues.
  • Shouldn’t need to specify QoS unless for example you start a process in the main queue and want it to go in the background specifically. Otherwise let the system determine the QoS for you.