   private let filled = dispatch_semaphore_create(0)!
   private let empty =  dispatch_semaphore_create(1)!
 
-  // private var lock = OS_SPINLOCK_INIT
-
   private var closed = false
 
   deinit

  }

  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)


  public func get() -> Int?
  {
    if closed && tail &- head <= 0 { return nil }

    dispatch_semaphore_wait(filled, DISPATCH_TIME_FOREVER)

    if tail &- head > 0
    {
      let e = element
      head = head &+ 1

      dispatch_semaphore_signal(empty)
      return e
    }
    else
    {
      assert(closed, __FUNCTION__)
      dispatch_semaphore_signal(filled)
      return nil
    }
