 
   final override func put(newElement: T) -> Bool
   {
-    if closed { return false }
+    if closed != 0 { return false }
 
     empty.wait()
-    OSSpinLockLock(&wlock)
-
-    if !closed
-    {
-      buffer.advancedBy(tail&mask).initialize(newElement)
-      tail = tail &+ 1
-
-      OSSpinLockUnlock(&wlock)
+
+    if closed == 0
+    {
+      let index = OSAtomicIncrementLongBarrier(&tail)
+      buffer.advancedBy(index&mask).initialize(newElement)
+
       filled.signal()
       return true
     }
     else
     {
-      OSSpinLockUnlock(&wlock)
       empty.signal()
       return false
     }


  final override var isFull: Bool
  {
      return (tail &- head) >= capacity
  }

  /**
    Determine whether the channel has been closed
  */

  final override var isClosed: Bool { return closed }

  // MARK: ChannelType methods


    }
  }
}

@inline(__always) private func OSAtomicIncrementLongBarrier(pointer: UnsafeMutablePointer<Int>) -> Int
{
  #if arch(x86_64) || arch(arm64) // 64-bit architecture
    return Int(OSAtomicIncrement64Barrier(UnsafeMutablePointer<Int64>(pointer)))
  #else // 32-bit architecture
    return Int(OSAtomicIncrement32Barrier(UnsafeMutablePointer<Int32>(pointer)))
  #endif
}

@inline(__always) private func OSAtomicDecrementLongBarrier(pointer: UnsafeMutablePointer<Int>) -> Int
{
  #if arch(x86_64) || arch(arm64) // 64-bit architecture
    return Int(OSAtomicDecrement64Barrier(UnsafeMutablePointer<Int64>(pointer)))
  #else // 32-bit architecture
    return Int(OSAtomicDecrement32Barrier(UnsafeMutablePointer<Int32>(pointer)))
  #endif
}
