{"action":"created","issue":{"url":"https://api.github.com/repos/manastech/crystal/issues/2056","labels_url":"https://api.github.com/repos/manastech/crystal/issues/2056/labels{/name}","comments_url":"https://api.github.com/repos/manastech/crystal/issues/2056/comments","events_url":"https://api.github.com/repos/manastech/crystal/issues/2056/events","html_url":"https://github.com/manastech/crystal/issues/2056","id":128407918,"number":2056,"title":"Can someone explain `IO::FileDescriptor#wait_readable` to me please?","user":{"login":"stugol","id":1113153,"avatar_url":"https://avatars.githubusercontent.com/u/1113153?v=3","gravatar_id":"","url":"https://api.github.com/users/stugol","html_url":"https://github.com/stugol","followers_url":"https://api.github.com/users/stugol/followers","following_url":"https://api.github.com/users/stugol/following{/other_user}","gists_url":"https://api.github.com/users/stugol/gists{/gist_id}","starred_url":"https://api.github.com/users/stugol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stugol/subscriptions","organizations_url":"https://api.github.com/users/stugol/orgs","repos_url":"https://api.github.com/users/stugol/repos","events_url":"https://api.github.com/users/stugol/events{/privacy}","received_events_url":"https://api.github.com/users/stugol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-24T16:31:35Z","updated_at":"2016-01-24T20:12:43Z","closed_at":null,"body":"I'm trying to figure out `IO::FileDescriptor#wait_readable`, `IO::FileDescriptor#add_read_event` and `Scheduler::create_fd_read_event`. I don't understand why all these complicated functions are necessary. Surely `IO::FileDescriptor#unbuffered_read` could just be written like this?\r\n```\r\nprivate def unbuffered_read(slice : Slice(UInt8))\r\n\tcount = slice.size\r\n\tloop do\r\n\t\tbytes_read = LibC.read(@fd, slice.pointer(count), count)\r\n\t\treturn bytes_read if bytes_read != -1\r\n\t\traise Errno.new \"Error reading file\" unless LibC.errno == Errno::EAGAIN\r\n\t\tFiber.yield\r\n\tend\r\nend\r\n```"},"comment":{"url":"https://api.github.com/repos/manastech/crystal/issues/comments/174336631","html_url":"https://github.com/manastech/crystal/issues/2056#issuecomment-174336631","issue_url":"https://api.github.com/repos/manastech/crystal/issues/2056","id":174336631,"user":{"login":"ysbaddaden","id":47380,"avatar_url":"https://avatars.githubusercontent.com/u/47380?v=3","gravatar_id":"","url":"https://api.github.com/users/ysbaddaden","html_url":"https://github.com/ysbaddaden","followers_url":"https://api.github.com/users/ysbaddaden/followers","following_url":"https://api.github.com/users/ysbaddaden/following{/other_user}","gists_url":"https://api.github.com/users/ysbaddaden/gists{/gist_id}","starred_url":"https://api.github.com/users/ysbaddaden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysbaddaden/subscriptions","organizations_url":"https://api.github.com/users/ysbaddaden/orgs","repos_url":"https://api.github.com/users/ysbaddaden/repos","events_url":"https://api.github.com/users/ysbaddaden/events{/privacy}","received_events_url":"https://api.github.com/users/ysbaddaden/received_events","type":"User","site_admin":false},"created_at":"2016-01-24T20:12:42Z","updated_at":"2016-01-24T20:12:42Z","body":"I'm not familiar with libevent too, but it's a kind of cross platform wrapper for kernel systems like epoll, "}}