               dispatch_set_context(s, nil)
               dispatch_semaphore_signal(s)
 
-            case let context:
-              let reader = Unmanaged<dispatch_semaphore_t>.fromOpaque(COpaquePointer(context)).takeRetainedValue()
-              assert(reader === rs, __FUNCTION__)
+            case waitSelect:
+              // rs's context should now be a pointer to a buffer.
+              assert(dispatch_get_context(rs) != waitSelect, __FUNCTION__)
               // pass the rs semaphore on to insert()
               let selection = Selection(id: selectionID, semaphore: rs)
               dispatch_set_context(s, UnsafeMutablePointer<Void>(Unmanaged.passRetained(selection).toOpaque()))
               dispatch_semaphore_signal(s)
+
+            case let context: // default
+              preconditionFailure("Context \(context) is invalid in waitSelect case of \(__FUNCTION__)")
             }
           }
           else


  override func selectGet(semaphore: SemaphoreChan, selectionID: Selectable) -> Signal
  {
    let threadLock = dispatch_semaphore_create(0)!

    dispatch_async(dispatch_get_global_queue(qos_class_self(), 0)) {
      _ in


      dispatch_set_context(threadLock, waitSelect)
      self.readerQueue.enqueue(threadLock)
      cancelable = true
      OSSpinLockUnlock(&self.lock)
      dispatch_semaphore_wait(threadLock, DISPATCH_TIME_FOREVER)

      // got awoken
      switch dispatch_get_context(threadLock)
      {
      case nil:
        // thread was awoken by close(): no more data on the channel
