     }
     init(buffer: Int){
         cap = buffer
+    }
+    func count() -> Int{
+        if cap == 0 {
+            return 0
+        }
+        return msgs.count
+    }
+    func capacity() -> Int{
+        return cap
     }
     func close(){
         cond.locker.lock()

    var flag = false
    let (v, ok, ready) = r.receive(true, mutex: nil, flag: &flag)
    return v as? T
}
private struct GoPanicError {
    var what: AnyObject?

    func send(msg : Any?)
    func close()
    func signal()
    func count() -> Int
    func capacity() -> Int
}
class Chan<T> : ChanAny {
    private var msgs = [Any?]()
