   {
     // the `empty` semaphore has already been decremented for this operation.
     OSSpinLockLock(&wlock)
-    if !closed && head+capacity > tail
+    if closed == 0 && (tail &- head) < capacity
     {
       buffer.advancedBy(tail&mask).initialize(newElement)
       tail = tail &+ 1


  deinit
  {
    while tail &- head > 0
    {
      buffer.advancedBy(head&mask).destroy()
      head = head &+ 1

    }
    else
    {
      assert(closed != 0, __FUNCTION__)
      OSSpinLockUnlock(&rlock)
      filled.signal()
      return nil
