title: Modifying reference type parameters in Swift; are changes immediately visible outside?
body: <p>I have a Swift playground that contains several classes in the source folder. These classes have <code>tick()</code> functions that are called as fast as possible with a <code>while true { }</code>. I am using a parallel thread to do this, to stop Xcode from locking up, with this code:</p>
  
  <pre><code>DispatchQueue.global(qos: .background).async {
      BackgroundThread.startMainLoop(scene: scene)
  }
  
  // other file
  public struct BackgroundThread {
      public static func startMainLoop (scene: SKScene) {
          let songController = SongController()
          let uiManager = UIManager(scene: scene)
  
  // The UIManager is going to modify this scene.
  // Will the changes be available to BackgroundThread and/or the main file?
  
          while true {
              songController.tick()
              uiManager.tick()
          }
      }
  }
  </code></pre>
  
  <p>Because the main playground script is very slow, I have moved the repeating loop to a compiled class in the Sources folder.</p>
  
  <p>I am passing an <code>SKScene</code> object to a <code>UIManager</code> compiled class, which I will need to update the UI in this (relatively complicated) scene faster than the main playground script can manage.</p>
  
  <p>The main playground script calls a <code>startMainLoop()</code> function in the parallel thread. It passes in the <code>SKScene</code> object. This function never returns, since it contains a never-ending loop. Is there a way I can modify the passed object in a manner that modifies the scene displayed on the screen, live, without the function ever having to return (which means that <code>inout</code> is not an option), assuming this does not happen by default?</p>