title: Grand Central Dispatch: Queue vs Semaphore for controlling access to a data structure?
body: <p>I'm doing this with Macruby, but I don't <em>think</em> that should matter much here.</p>
  
  <p>I've got a model which stores its state in a dictionary data structure. I want concurrent operations to be updating this data structure sporadically. It seems to me like GCD offers a few possible solutions to this, including these two:</p>
  
  <ul>
  <li>wrap any code that accesses the data structure in a block sent to some serial queue</li>
  <li>use a GCD semaphore, with client code sending wait/signal calls as necessary when accessing the structure</li>
  </ul>
  
  <p>When the queues in the first solution are synchronously called, then it seems pretty much equivalent to the semaphore solution. Do either of these solutions have clear advantages that I'm missing? Is there a better alternative I'm missing?</p>
  
  <p>Also: would it be straightforward to implement a read-write (shared-exclusive) lock with GCD?</p>