 
     if closed && head >= tail
     {
+      if !writerQueue.isEmpty, let ws = writerQueue.dequeue()
+      {
+        dispatch_semaphore_signal(ws)
+      }
+      else if head < tail || closed
+      {
+        if !readerQueue.isEmpty, let rs = readerQueue.dequeue()
+        {
+          dispatch_semaphore_signal(rs)
+        }
+      }
       OSSpinLockUnlock(&lock)
       return nil
     }

    OSSpinLockLock(&lock)
    closed = true

    // Unblock the threads waiting on our conditions.
    if readerQueue.isEmpty == false
    {
      while let rs = readerQueue.dequeue()
      {
        dispatch_semaphore_signal(rs)
      }
    }
    if writerQueue.isEmpty == false
    {
      while let ws = writerQueue.dequeue()
      {
        dispatch_semaphore_signal(ws)
      }
    }
    OSSpinLockUnlock(&lock)
  }

    {
      dispatch_semaphore_signal(ws)
    }
    else if head < tail || closed
    {
      if !readerQueue.isEmpty, let rs = readerQueue.dequeue()
      {
