 
             if readBuffer!.count >= needed {
                 let result = readBuffer!
-                item.completion(result)
-
                 readBuffer = nil
                 _ = readQueue.removeFirst()
+                item.completion(result)
             }
 
             wantReadEvents = readQueue.count > 0


    private var wantReadEvents = false {
        didSet {
            switch (oldValue, wantReadEvents) {
                case (true, false): rsource.suspend()
                case (false, true): rsource.resume()


    private var wantWriteEvents = false {
        didSet {
            guard isOpen else { return }
            switch (oldValue, wantWriteEvents) {
                case (true, false): wsource.suspend()
                case (false, true): wsource.resume()
