     OSSpinLockLock(&lock)
     if let rs = readerQueue.dequeue()
     {
-      if dispatch_get_context(rs) != waitSelect
-      {
+      switch dispatch_get_context(rs)
+      {
+      case nil, cancelSelect:
+        preconditionFailure("Context is invalid in \(__FUNCTION__)")
+
+      case waitSelect:
+        readerQueue.undequeue(rs)
+
+      default:
         OSSpinLockUnlock(&lock)
         return Selection(selectionID: selectionID, selectionData: rs)
       }
-      readerQueue.undequeue(rs)
     }
     OSSpinLockUnlock(&lock)
     return nil

    OSSpinLockLock(&lock)
    if let ws = writerQueue.dequeue()
    {
      OSSpinLockUnlock(&lock)

      let context = UnsafePointer<T>(dispatch_get_context(ws))
      switch context
      {
      case nil, UnsafePointer(cancelSelect):
        preconditionFailure(__FUNCTION__)

      default:
        let element = context.memory
        dispatch_set_context(ws, nil)
        dispatch_semaphore_signal(ws)

        return Selection(selectionID: selectionID, selectionData: element)
      }
    }

    if let rs: dispatch_semaphore_t = selection.getData()
    {
      let context = UnsafeMutablePointer<T>(dispatch_get_context(rs))
      context.initialize(newElement)
      dispatch_semaphore_signal(rs)
      return true
    }
    assert(false, "Thread left hanging in \(__FUNCTION__), semaphore not found in \(selection)")
    return false
