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

Shared, Exclusive, Mutable, Immutable

Shared, Exclusive, Mutable, Immutable

NSBudapest, May 2018

Greg Heo

May 10, 2018
Tweet

More Decks by Greg Heo

Other Decks in Technology

Transcript

  1. @gregheo ! NSBudapest, May 2018
    Shared

    Exclusive

    Mutable

    Immutable

    View full-size slide

  2. @gregheo ! NSBudapest, May 2018
    Data
    "

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  6. @gregheo ! NSBudapest, May 2018
    Exclusive Shared
    Immutable private let
    Screen size /
    scale
    Mutable
    private var

    private queue
    $

    View full-size slide

  7. @gregheo ! NSBudapest, May 2018
    Fewer entry points

    View full-size slide

  8. @gregheo ! NSBudapest, May 2018
    Private queues

    View full-size slide

  9. @gregheo ! NSBudapest, May 2018
    Queue Callback

    View full-size slide

  10. @gregheo ! NSBudapest, May 2018

    // call from anywhere!

    public func something() {

    privateQueue.sync { … }
    }


    View full-size slide

  11. @gregheo ! NSBudapest, May 2018

    // always call on the main queue!

    public func something() 


    View full-size slide

  12. @gregheo ! NSBudapest, May 2018

    // always call on the main queue!

    public func something() {

    dispatchPrecondition(condition: .onQueue(.main))

    }


    View full-size slide

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

    to get wrong

    View full-size slide

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

    View full-size slide