 
 final class SBufferedNChan<T>: Chan<T>
 {
-  private var q = PointerQueue<T>()
+  private var buffer: UnsafeMutablePointer<T>
 
   // housekeeping variables
 
-  private let capacity: Int
+  private final let capacity: Int
+  private final let mask: Int
+
+  // housekeeping variables
+
+  private final var head = 0
+  private final var tail = 0
+
+  private final var headptr: UnsafeMutablePointer<T>
+  private final var tailptr: UnsafeMutablePointer<T>
 
   private let filled: dispatch_semaphore_t
   private let empty:  dispatch_semaphore_t

    self.init(1)
  }

  // Computed property accessors

  final override var isEmpty: Bool
  {
    return q.count <= 0
  }

  final override var isFull: Bool
  {
    return q.count >= capacity
  }

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


    if !closed
    {
      tailptr.initialize(newElement)
      tailptr = tailptr.successor()
      tail += 1
      if (tail&mask == 0) { tailptr = buffer }
    }

    dispatch_semaphore_signal(mutex)
