Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Shared, Exclusive, Mutable, Immutable

Shared, Exclusive, Mutable, Immutable

NSBudapest, May 2018

06609d73ad2165c4aafcf65a1ddb9563?s=128

Greg Heo

May 10, 2018
Tweet

Transcript

  1. @gregheo ! NSBudapest, May 2018 Shared
 Exclusive
 Mutable
 Immutable

  2. @gregheo ! NSBudapest, May 2018 Data "

  3. @gregheo ! NSBudapest, May 2018 Code Example #

  4. @gregheo ! NSBudapest, May 2018 Exclusive Shared Immutable Mutable

  5. @gregheo ! NSBudapest, May 2018 Exclusive Shared Immutable Mutable

  6. @gregheo ! NSBudapest, May 2018 Exclusive Shared Immutable private let

    Screen size / scale Mutable private var
 private queue $
  7. @gregheo ! NSBudapest, May 2018 Fewer entry points

  8. @gregheo ! NSBudapest, May 2018 Private queues

  9. @gregheo ! NSBudapest, May 2018 Queue Callback

  10. @gregheo ! NSBudapest, May 2018 
 // call from anywhere!


    public func something() {
 privateQueue.sync { … } }

  11. @gregheo ! NSBudapest, May 2018 
 // always call on

    the main queue!
 public func something() 

  12. @gregheo ! NSBudapest, May 2018 
 // always call on

    the main queue!
 public func something() {
 dispatchPrecondition(condition: .onQueue(.main))
 }

  13. @gregheo ! NSBudapest, May 2018 Make it difficult
 to get

    wrong
  14. @gregheo ! NSBudapest, May 2018 köszönöm! ☺