             let selectptr = UnsafeMutablePointer<Void>(Unmanaged.passRetained(selection).toOpaque())
             dispatch_set_context(s, selectptr)
             dispatch_semaphore_signal(s)
-            return
-          }
-        }
-        else
-        {
-          self.writerQueue.undequeue(ws)
-          // The spinlock stayed locked between dequeue() and undequeue(),
-          // so it was transparent to other threads.
-          OSSpinLockUnlock(&self.lock)
-          return
-        }
+          }
+          else
+          {
+            self.writerQueue.undequeue(ws)
+            // The spinlock stayed locked between dequeue() and undequeue(),
+            // so it was transparent to other threads.
+            OSSpinLockUnlock(&self.lock)
+          }
+        }
+        return
       }
 
       if self.closed

        preconditionFailure(__FUNCTION__)

      case waitSelect:
        writerQueue.undequeue(ws)

      default:

      OSSpinLockLock(&self.lock)
      if let rs = self.readerQueue.dequeue()
      {
        let context = dispatch_get_context(rs)
        switch context
        {
        case nil:
          preconditionFailure(__FUNCTION__)

        case waitSelect:
          if let s = semaphore.get()
          {
            OSSpinLockUnlock(&self.lock)
            dispatch_set_context(threadLock, waitSelect)
            let contextptr = UnsafeMutablePointer<Void>(Unmanaged.passRetained(threadLock).toOpaque())
            dispatch_set_context(rs, contextptr)
            dispatch_semaphore_signal(rs)
            dispatch_semaphore_wait(threadLock, DISPATCH_TIME_FOREVER)

            let context = dispatch_get_context(threadLock)
            switch context
            {
            case nil:
              dispatch_set_context(s, nil)
              dispatch_semaphore_signal(s)

            default:
              let rs = Unmanaged<dispatch_semaphore_t>.fromOpaque(COpaquePointer(context)).takeRetainedValue()
              let selection = Selection(selectionID: selectionID, selectionData: rs)
              let selectptr = UnsafeMutablePointer<Void>(Unmanaged.passRetained(selection).toOpaque())
              dispatch_set_context(s, selectptr)
              dispatch_semaphore_signal(s)
            }
          }
          else
          {
            self.readerQueue.undequeue(rs)
            // The spinlock stayed locked between dequeue() and undequeue(),
            // so it was transparent to other threads.
            OSSpinLockUnlock(&self.lock)
          }

        default:
          if let s = semaphore.get()
          {
            OSSpinLockUnlock(&self.lock)
            let selection = Selection(selectionID: selectionID, selectionData: rs)
            let selectptr = UnsafeMutablePointer<Void>(Unmanaged.passRetained(selection).toOpaque())
            dispatch_set_context(s, selectptr)
            dispatch_semaphore_signal(s)
          }
          else
          {
            self.readerQueue.undequeue(rs)
            // The spinlock stayed locked between dequeue() and undequeue(),
            // so it was transparent to other threads.
            OSSpinLockUnlock(&self.lock)
          }
        }
        return
      }

      if self.closed
