 
   public func get() -> Int?
   {
-    if closed && head >= tail { return nil }
+    if closed && tail &- head <= 0 { return nil }
 
     dispatch_semaphore_wait(filled, DISPATCH_TIME_FOREVER)
-    // OSSpinLockLock(&lock)
 
-    if head < tail
+    if tail &- head > 0
     {
       let e = element
-      head++
+      head = head &+ 1
 
-      // OSSpinLockUnlock(&lock)
       dispatch_semaphore_signal(empty)
       return e
     }
     else
     {
       assert(closed, __FUNCTION__)
-      // OSSpinLockUnlock(&lock)
       dispatch_semaphore_signal(filled)
       return nil
     }

  }

  public var isClosed: Bool { return closed }
  public var isEmpty: Bool { return head >= tail }
  public var isFull: Bool { return head < tail }

  public func close()
  {
    if closed { return }

    // OSSpinLockLock(&lock)
    closed = true
    // OSSpinLockUnlock(&lock)

    dispatch_semaphore_signal(empty)
    dispatch_semaphore_signal(filled)

  private let filled = dispatch_semaphore_create(0)!
  private let empty =  dispatch_semaphore_create(1)!

  private var closed = false

  deinit
