         
         
         // Fail all pending writes and so ensure all pending promises are notified
-        failPendingWrites(err: IOError(errno: EBADF, reason: "Channel closed"))
+        pendingWrites.failAll(error: IOError(errno: EBADF, reason: "Channel closed"))
     }
     
     func registerOnEventLoop(initPipeline: (ChannelPipeline) throws ->()) {

import Darwin
#endif

public class Channel : ChannelOutboundInvoker {
    public private(set) var open: Bool = true


    }

    private func flushNow() -> Bool {
        while open {
            do {
                if let written = try pendingWrites.consumeNext(body: {
                    return try self.socket.write(pointer: $0, size: $1)
                }) {
                    if !written {
                        // Could not write the next buffer completely
                        return false
                    }
                } else {
                    // we handled all writes
                    return true
                }
                
            } catch let err {
                // fail all pending writes so all promises are notified.
                failPendingWritesAndClose(err: err)
                
