 /// EventLoop uses given selector to monitor IO events, trigger callbacks when needed to
 /// Follow Python EventLoop design https://docs.python.org/3/library/asyncio-eventloop.html
 public final class EventLoop {
-    private var thread: NSThread!
     private let selector: SelectorType
     // these are for self-pipe-trick ref: https://cr.yp.to/docs/selfpipe.html
     // to be able to interrupt the blocking selector, we create a pipe and add it to the

    
    func stop() {
        running = false
        try! interruptSelector()
    }
    
    // interrupt the selector
    private func interruptSelector() throws {
        let byte = [UInt8](count: 1, repeatedValue: 0)
        guard send(pipeSender, byte, byte.count, 0) >= 0 else {
            throw OSError.lastIOError()
        }
    }
    
    // Run once iteration for the event loop
    private func runOnce() {
    }
    
    @objc private func runLoop() {
        while running {
            let events = try! selector.select(nil)
            for (key, ioEvents) in events {
                // skip pipe receiver interrupting event
                guard key.fileDescriptor != pipeReceiver else {
                    continue
                }
                // TODO: handle the event here
            }
        }
    }
    
}

        pipeSender = pipeFds[0]
        pipeReceiver = pipeFds[1]
        
        // subscribe to pipe receiver read-ready event, do nothing, just allow selector
        // to be interrupted
        setReader(pipeReceiver) {}
    }
    
    deinit {
        stop()
        close(pipeSender)
        close(pipeReceiver)
    }
