     OSSpinLockLock(&lock)
     closed = true
 
-    // Unblock waiting threads.
-    signalNextReader() || signalNextWriter()
-    OSSpinLockUnlock(&lock)
-  }
-
-  /**
-    Stop the thread on a new semaphore obtained from the SemaphorePool
-
-    The new semaphore is enqueued to readerQueue or writerQueue, and
-    will be used as a signal to resume the thread at a later time.
-
-    :param: lock a semaphore that is currently held by the calling thread.
-    :param: queue the queue to which the signal should be appended
-  */
-
-  private func wait(queue: FastQueue<SuperSemaphore>)
-  {
-    precondition(lock != 0, "Lock must be locked upon entering \(__FUNCTION__)")
-
-    let threadLock = SemaphorePool.Obtain()
-    queue.enqueue(.semaphore(threadLock))
-    OSSpinLockUnlock(&lock)
-    threadLock.wait()
-    SemaphorePool.Return(threadLock)
-    OSSpinLockLock(&lock)
-  }
-  
-  private func wait(queue: FastQueue<QueuedSemaphore>)
-  {
-    precondition(lock != 0, "Lock must be locked upon entering \(__FUNCTION__)")
-
-    let threadLock = SemaphorePool.Obtain()
-    queue.enqueue(QueuedSemaphore(threadLock))
-    OSSpinLockUnlock(&lock)
-    threadLock.wait()
-    SemaphorePool.Return(threadLock)
-    OSSpinLockLock(&lock)
-  }
-  
-  private func signalNextReader() -> Bool
-  {
+    // Unblock every waiting thread.
     while let reader = readerQueue.dequeue()
     {
       switch reader.sem.state
       {
       case .Ready:
-        return reader.sem.signal()
+        reader.sem.signal()
 
       case .WaitSelect:
-        if reader.sem.setState(.Select)
-        {
-          nextget += 1
-          reader.sem.selection = reader.sel!
-          return reader.sem.signal()
-        }
+        if reader.sem.setState(.Invalidated) { reader.sem.signal() }
 
       default:
         assertionFailure("Unexpected case \(reader.sem.state.rawValue) in \(__FUNCTION__)")
       }
     }
-    return false
-  }
-
-  private func signalNextWriter() -> Bool
-  {
     while let writer = writerQueue.dequeue()
     {
       switch writer.sem.state
       {
       case .Ready:
-        return writer.sem.signal()
+        writer.sem.signal()
 
       case .WaitSelect:
-        if writer.sem.setState(.Select)
-        {
-          nextput += 1
-          writer.sem.selection = writer.sel!
-          return writer.sem.signal()
-        }
+        if writer.sem.setState(.Invalidated) { writer.sem.signal() }
 
       default:
         assertionFailure("Unexpected case \(writer.sem.state.rawValue) in \(__FUNCTION__)")
       }
     }
-    return false
+    OSSpinLockUnlock(&lock)
   }
 
   /**

      let element = buffer.advancedBy(Int(head&mask)).move()
      head += 1

      if !signalNextWriter()
      {
        if nextget < tail || closed { signalNextReader() }
      }
      OSSpinLockUnlock(&lock)
      return element

      }
      else
      {
        while let writer = writerQueue.dequeue()
        {
          switch writer.sem.state
          {
          case .Ready:
            writer.sem.signal()
            OSSpinLockUnlock(&lock)
            return

          case .WaitSelect:
            if writer.sem.setState(.Select)
            {
              nextput += 1
              writer.sem.selection = writer.sel!
              writer.sem.signal()
              OSSpinLockUnlock(&lock)
              return
            }

          default:
            assertionFailure("Unexpected case \(writer.sem.state.rawValue) in \(__FUNCTION__)")
          }
        }
        while nextget < tail || closed, let reader = readerQueue.dequeue()
        {
          switch reader.sem.state
          {
          case .Ready:
            reader.sem.signal()
            OSSpinLockUnlock(&lock)
            return

          case .WaitSelect:
            if reader.sem.setState(.Select)
            {
              nextget += 1
              reader.sem.selection = reader.sel!
              reader.sem.signal()
              OSSpinLockUnlock(&lock)
              return
            }

          default:
            assertionFailure("Unexpected case \(reader.sem.state.rawValue) in \(__FUNCTION__)")
          }
        }
        OSSpinLockUnlock(&lock)
      }
