{"action":"created","issue":{"url":"https://api.github.com/repos/celluloid/nio4r/issues/64","labels_url":"https://api.github.com/repos/celluloid/nio4r/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/celluloid/nio4r/issues/64/comments","events_url":"https://api.github.com/repos/celluloid/nio4r/issues/64/events","html_url":"https://github.com/celluloid/nio4r/pull/64","id":64735107,"number":64,"title":"Separate Selector#select return value for timeout/wakeup","user":{"login":"Burgestrand","id":99166,"avatar_url":"https://avatars.githubusercontent.com/u/99166?v=3","gravatar_id":"","url":"https://api.github.com/users/Burgestrand","html_url":"https://github.com/Burgestrand","followers_url":"https://api.github.com/users/Burgestrand/followers","following_url":"https://api.github.com/users/Burgestrand/following{/other_user}","gists_url":"https://api.github.com/users/Burgestrand/gists{/gist_id}","starred_url":"https://api.github.com/users/Burgestrand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Burgestrand/subscriptions","organizations_url":"https://api.github.com/users/Burgestrand/orgs","repos_url":"https://api.github.com/users/Burgestrand/repos","events_url":"https://api.github.com/users/Burgestrand/events{/privacy}","received_events_url":"https://api.github.com/users/Burgestrand/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-27T10:28:39Z","updated_at":"2015-03-28T18:33:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/celluloid/nio4r/pulls/64","html_url":"https://github.com/celluloid/nio4r/pull/64","diff_url":"https://github.com/celluloid/nio4r/pull/64.diff","patch_url":"https://github.com/celluloid/nio4r/pull/64.patch"},"body":"This PR is related to  #63.\r\n\r\nReturn values:\r\n```\r\nwakeup: false\r\ntimeout: nil\r\n```\r\n\r\nFor pure implementation we return nil if Kernel.select returns nil, this does not handle spurious wakeups properly (they'd return `nil`), but after some research I'm not entirely sure that spurious wakeups *can* happen. If we decide it's important we could probably use the same approach that is used in the JRuby extension and time the `select()` call, if it returns early and the number of ready selectors is 0 then we have a wakeup.\r\n\r\nFor C implementation we return nil if the timed_out flag was set as part of the timeout timer, or if the busy loop determines we have timed out.\r\n\r\nFor Java implementation we calculate time spent waiting for select(), if it is longer than the specified timeout we assume that we have timed out.\r\n\r\nI didn't manage to find a good way to test spurious wakeups. `Thread#wakeup` did not appear to cause `select()` to wake up at all."},"comment":{"url":"https://api.github.com/repos/celluloid/nio4r/issues/comments/87280578","html_url":"https://github.com/celluloid/nio4r/pull/64#issuecomment-87280578","issue_url":"https://api.github.com/repos/celluloid/nio4r/issues/64","id":87280578,"user":{"login":"tarcieri","id":797,"avatar_url":"https://avatars.githubusercontent.com/u/797?v=3","gravatar_id":"","url":"https://api.github.com/users/tarcieri","html_url":"https://github.com/tarcieri","followers_url":"https://api.github.com/users/tarcieri/followers","following_url":"https://api.github.com/users/tarcieri/following{/other_user}","gists_url":"https://api.github.com/users/tarcieri/gists{/gist_id}","starred_url":"https://api.github.com/users/tarcieri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tarcieri/subscriptions","organizations_url":"https://api.github.com/users/tarcieri/orgs","repos_url":"https://api.github.com/users/tarcieri/repos","events_url":"https://api.github.com/users/tarcieri/events{/privacy}","received_events_url":"https://api.github.com/users/tarcieri/received_events","type":"User","site_admin":false},"created_at":"2015-03-28T18:33:12Z","updated_at":"2015-03-28T18:33:12Z","body":"It also seems like there are more direct ways to determine whether it was a timeout than trying to measure time yourself, e.g. if nothing was selected"}}