   override func selectGet(semaphore: SemaphoreChan, selectionID: Selectable)
   {
     OSSpinLockLock(&lock)
-    if !writerQueue.isEmpty
-    {
-      if let s = semaphore.get()
-      {
-        if let ws = selectGetNow()
-        {
+    while let wss = writerQueue.dequeue()
+    {
+      switch wss
+      {
+      case .semaphore(let ws):
+        if let select = semaphore.get()
+        {
+          OSSpinLockUnlock(&lock)
           let selection = Selection(id: selectionID, semaphore: ws)
-          dispatch_set_context(s, UnsafeMutablePointer<Void>(Unmanaged.passRetained(selection).toOpaque()))
-        }
-        OSSpinLockUnlock(&lock)
-        dispatch_semaphore_signal(s)
-      }
-      else
-      {
-        OSSpinLockUnlock(&lock)
-      }
-      return
+          dispatch_set_context(select, UnsafeMutablePointer<Void>(Unmanaged.passRetained(selection).toOpaque()))
+          dispatch_semaphore_signal(select)
+        }
+        else
+        {
+          writerQueue.undequeue(wss)
+          OSSpinLockUnlock(&lock)
+        }
+        return
+
+      case .selection(let c, let insertSelectionID):
+        if !c.isEmpty
+        {
+          if let select = semaphore.get()
+          {
+            OSSpinLockUnlock(&lock)
+            if let insertSelect = c.get()
+            {
+              let selection = Selection(id: selectionID, semaphore: extractFromInsert(insertSelect, id: insertSelectionID))
+              dispatch_set_context(select, UnsafeMutablePointer<Void>(Unmanaged.passRetained(selection).toOpaque()))
+            }
+            dispatch_semaphore_signal(select)
+          }
+          else
+          {
+            writerQueue.undequeue(wss)
+            OSSpinLockUnlock(&lock)
+          }
+          return
+        }
+      }
     }
 
     if closed
     {
       OSSpinLockUnlock(&lock)
-      if let s = semaphore.get()
-      {
-        dispatch_semaphore_signal(s)
+      if let select = semaphore.get()
+      {
+        dispatch_semaphore_signal(select)
       }
       return
     }

  override func selectGetNow(selectionID: Selectable) -> Selection?
  {
    OSSpinLockLock(&lock)
    if let ws = selectGetNow()
    {
      OSSpinLockUnlock(&lock)
      return Selection(id: selectionID, semaphore: ws)
    }
    OSSpinLockUnlock(&lock)
    return nil
  }

  private func selectGetNow() -> dispatch_semaphore_t?
  {
    precondition(lock != 0, __FUNCTION__)
    while let ssema = writerQueue.dequeue()
    {
      switch ssema
      {
      case .semaphore(let ws):
        return ws

      case .selection(let c, let selectionID):
        if let s = c.get()
        {
          OSSpinLockUnlock(&lock)
          let mediator = SemaphorePool.dequeue()
          let buffer = UnsafeMutablePointer<T>.alloc(1)
          dispatch_set_context(mediator, buffer)
          let selection = Selection(id: selectionID, semaphore: mediator)
          dispatch_set_context(s, UnsafeMutablePointer<Void>(Unmanaged.passRetained(selection).toOpaque()))
          dispatch_semaphore_signal(s)
          dispatch_semaphore_wait(mediator, DISPATCH_TIME_FOREVER)
          // got awoken by insert()
          precondition(dispatch_get_context(mediator) == buffer, "Unknown context in \(__FUNCTION__)")

          // two select()s talking to each other need a 3rd thread
          dispatch_async(dispatch_get_global_queue(QOS_CLASS_UTILITY, 0)) {
            dispatch_semaphore_wait(mediator, DISPATCH_TIME_FOREVER)
            // got awoken by extract()
            buffer.destroy(1)
            buffer.dealloc(1)
            dispatch_set_context(mediator, nil)
            SemaphorePool.enqueue(mediator)
          }
          OSSpinLockLock(&lock)
          return mediator
        }
        else
        { // try the next enqueued reader instead
          continue
        }
      }
    }
    return nil
  }
  
  override func extract(selection: Selection) -> T?
  {
    if let ws = selection.semaphore

  override func selectPut(semaphore: SemaphoreChan, selectionID: Selectable)
  {
    OSSpinLockLock(&lock)
    while let rss = readerQueue.dequeue()
    {
      switch rss
      {
      case .semaphore(let rs):
        if let select = semaphore.get()
        {
          OSSpinLockUnlock(&lock)
          let selection = Selection(id: selectionID, semaphore: rs)
          dispatch_set_context(select, UnsafeMutablePointer<Void>(Unmanaged.passRetained(selection).toOpaque()))
          dispatch_semaphore_signal(select)
        }
        else
        {
          readerQueue.undequeue(rss)
          OSSpinLockUnlock(&lock)
        }
        return

      case .selection(let c, let extractSelectionID):
        if !c.isEmpty
        {
          if let select = semaphore.get()
          {
            OSSpinLockUnlock(&lock)
            if let extractSelect = c.get()
            {
              let selection = Selection(id: selectionID, semaphore: insertToExtract(extractSelect, id: extractSelectionID))
              dispatch_set_context(select, UnsafeMutablePointer<Void>(Unmanaged.passRetained(selection).toOpaque()))
            }
            dispatch_semaphore_signal(select)
          }
          else
          {
            readerQueue.undequeue(rss)
            OSSpinLockUnlock(&lock)
          }
          return
        }
      }
    }

    if closed
    {
      OSSpinLockUnlock(&lock)
      if let select = semaphore.get()
      {
        dispatch_semaphore_signal(select)
      }
      return
    }
