{"id":19885655,"url":"https://github.com/asmod4n/mruby-poll","last_synced_at":"2025-05-02T16:31:45.452Z","repository":{"id":76216493,"uuid":"62327334","full_name":"Asmod4n/mruby-poll","owner":"Asmod4n","description":"Low level system poll for mruby","archived":false,"fork":false,"pushed_at":"2024-10-24T16:48:01.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T03:34:23.409Z","etag":null,"topics":["mruby","networking"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Asmod4n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-30T16:46:12.000Z","updated_at":"2024-10-24T16:48:05.000Z","dependencies_parsed_at":"2023-12-31T11:37:41.189Z","dependency_job_id":"9ca35f46-7f6c-4c38-a5c5-70a3d79655a9","html_url":"https://github.com/Asmod4n/mruby-poll","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-poll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-poll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-poll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asmod4n%2Fmruby-poll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Asmod4n","download_url":"https://codeload.github.com/Asmod4n/mruby-poll/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252071842,"owners_count":21690099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mruby","networking"],"created_at":"2024-11-12T17:35:13.131Z","updated_at":"2025-05-02T16:31:45.172Z","avatar_url":"https://github.com/Asmod4n.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mruby-poll\nLow level system poll for mruby\n\nExample without a block\n=======================\n\n```ruby\npoll = Poll.new\n\npollfd = poll.add(STDOUT_FILENO, Poll::Out)\n\nif ready_fds = poll.wait\n  ready_fds.each do |ready_fd|\n    puts ready_fd\n  end\nend\n```\n\nExample with a block\n====================\n```ruby\npoll = Poll.new\n\npollfd = poll.add(STDOUT_FILENO, Poll::Out)\n\npoll.wait do |ready_fd|\n  if ready_fd == pollfd\n    puts \"got STDOUT_FILENO\"\n  end\nend\n```\n\n\"Documentation\"\n=============\n\n```ruby\nclass Poll\n  def add(socket, events = Poll::In) # adds a Ruby Socket/IO Object to the pollfds\n  # returns a Poll::Fd\n  def remove(fd) # deletes a Poll::Fd struct from the pollfds\n  def wait((optional) (int) timeout, \u0026block) # waits until a fd becomes ready, its using the poll function from \u003csys/poll.h\u003e\n  # returns \"false\" when the process gets interrupted\n  # returns \"nil\" when it times out\n  # returns a array when ready fds have been found, or self when a block is passed\n  # raises exceptions according to other errors\nend\n```\n\nFor other errors take a look at http://pubs.opengroup.org/onlinepubs/007908799/xsh/poll.html\n\n\n```ruby\nclass Poll\n  class Fd\n    def socket() # returns the socket\n    def socket=(socket) # # sets another socket\n    def events() # returns the events\n    def events=(events) # sets events\n    def revents() # returns the events after a poll()\n    def revents=(revents) # sets revents\n    def readable? # returns if the socket is readable\n    def writable? # returns if the socket is writable\n    def err? # returns if the socket is in a error state\n    def disconnected? # returns if the socket is disconnected\n  end\nend\n```\n\nEvents\n\n```ruby\nPoll::Err\nPoll::Hub\nPoll::In\nPoll::NVal\nPoll::Out\nPoll::Pri\n```\n\nFor what these events mean take a look at http://pubs.opengroup.org/onlinepubs/007908799/xsh/poll.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmod4n%2Fmruby-poll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasmod4n%2Fmruby-poll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasmod4n%2Fmruby-poll/lists"}