title: Swift + Async: How to execute a callback on the same thread where it was created?
body: <p>Using the <a href="https://github.com/duemunk/Async" rel="nofollow">Async</a> library, a simple pattern to do work on a background thread might look like this:</p>
  
  <pre><code>// Assume we start on the main thread
  
  let onResultComplete: (result: ResultType) -&gt; Void = { result in
      Async.main {
          // Code to handle one result at a time on the main thread
      }
  }
  
  Async.background {
      doCalculationsThatProduceManyResults(onEachResultComplete: onResultComplete)
  }
  </code></pre>
  
  <p>Now consider this scenario, where the code is already being executed on a background thread:</p>
  
  <pre><code>// Assume we start on some "unknown background thread"
  
  let onResultComplete: (result: ResultType) -&gt; Void = { result in
      Async.??? {
          // Code to handle one result at a time on the "unknown background thread"
      }
  }
  
  Async.background {
      doCalculationsThatProduceManyResults(onEachResultComplete: onResultComplete)
  }
  </code></pre>
  
  <p>How can I force the closure <code>onResultComplete</code> to be run on the <strong>same</strong> unknown background thread from where I called <code>Async.background</code>?</p>
  
  <p>I'm open to any suggestions that use GCD methods.</p>