[swift-evolution] [Concurrency] async/await + actors

William Jon Shipley wjs at delicious-monster.com
Thu Aug 17 19:47:24 CDT 2017


I think the comments on “prettify()” are from an earlier version of the sample code? The way it’s called it doesn’t look like it’d access theList at all.

  actor TableModel {
    let mainActor : TheMainActor
    var theList : [String] = [] {
      didSet {
        mainActor.updateTableView(theList)
      }
    }
    
    init(mainActor: TheMainActor) { self.mainActor = mainActor }

    // this checks to see if all the entries in the list are capitalized:
    // if so, it capitalize the string before returning it to encourage
    // capitalization consistency in the list.
    func prettify(_ x : String) -> String {
      // ... details omitted, it just pokes theList directly ...
    }

    actor func add(entry: String) {
      theList.append(prettify(entry))
    }
  }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170817/fcff60fa/attachment.html>


More information about the swift-evolution mailing list