{"id":17832407,"url":"https://github.com/ksss/epoll","last_synced_at":"2025-07-12T20:32:43.276Z","repository":{"id":22565611,"uuid":"25906938","full_name":"ksss/epoll","owner":"ksss","description":"epoll(7) binding in Ruby","archived":false,"fork":false,"pushed_at":"2015-01-06T23:44:57.000Z","size":427,"stargazers_count":22,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-25T03:12:15.792Z","etag":null,"topics":["epoll","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/ksss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-29T06:04:09.000Z","updated_at":"2024-04-20T10:45:15.000Z","dependencies_parsed_at":"2022-08-21T08:00:21.695Z","dependency_job_id":null,"html_url":"https://github.com/ksss/epoll","commit_stats":null,"previous_names":["ksss/io-epoll"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/ksss/epoll","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksss%2Fepoll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksss%2Fepoll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksss%2Fepoll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksss%2Fepoll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ksss","download_url":"https://codeload.github.com/ksss/epoll/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksss%2Fepoll/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265049108,"owners_count":23703470,"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":["epoll","ruby"],"created_at":"2024-10-27T19:56:48.042Z","updated_at":"2025-07-12T20:32:43.062Z","avatar_url":"https://github.com/ksss.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"epoll\n===\n\n[![Build Status](https://travis-ci.org/ksss/epoll.svg?branch=master)](https://travis-ci.org/ksss/epoll)\n\nA binding of epoll(7) on Ruby.\n\n**epoll(7)** can use Linux only. (because must be installed sys/epoll.h)\n\n# Usage\n\n```ruby\nrequire 'epoll'\n\n# Epoll \u003c IO\n\n# Epoll.create\n#   call epoll_create(2)\n#   it's just alias of `open`\n#   Epoll object stock a File Descriptor returned by epoll_create(2)\n#   return: instance of Epoll (kind of IO)\nepoll = Epoll.create\n\n# IO object add to interest list\n#   call epoll_ctl(2)\nepoll.add(io, Epoll::IN)  # same way to epoll.ctl(Epoll::CTL_ADD, io, Epoll::IN)\n\n# change waiting events\n#   call epoll_ctl(2)\nepoll.mod(io, Epoll::OUT) # same way to epoll.ctl(Epoll::CTL_MOD, io, Epoll::OUT)\n\n# remove from interest list\n#   call epoll_ctl(2)\nepoll.del(io)             # same way to epoll.ctl(Epoll::CTL_DEL, io)\n\nloop do\n  # Epoll#wait(timeout=-1)\n  #   call epoll_wait(2)\n  #   timeout = -1: block until receive event or signals\n  #   timeout = 0: return all io's can I/O on non block\n  #   timeout \u003e 0: block when timeout pass miri second or receive events or signals\n  #   return: Array of Epoll::Event\n  evlist = epoll.wait\n\n  # ev is instance of Epoll::Event like `struct epoll_event`\n  # it's instance of `class Epoll::Event \u003c Struct.new(:data, :events); end`\n  evlist.each do |ev|\n    # Epoll::Event#events is event flag bits (Fixnum)\n    if (ev.events \u0026 Epoll::IN) != 0\n      # Epoll::Event#data is notified IO (IO)\n      # e.g. it's expect to I/O readable\n      puts ev.data.read\n    elsif (ev.events \u0026 Epoll::HUP|Epoll::ERR) != 0\n      ev.data.close\n      break\n    end\n  end\nend\n\n# you can close File Descriptor for epoll when finish to use\nepoll.close #=\u003e nil\n\n# and you can check closed\nepoll.closed? #=\u003e true\n\n# and very useful way is that call `create` with block like `IO.open`\n# return: block result\nEpoll.create do |epoll|\n  # ensure automatic call `epoll.close` when out block\nend\n```\n\n## ctl options\n\nctl options|description\n---|---\n**Epoll::CTL_ADD**|add to interest list for created epoll fd\n**Epoll::CTL_MOD**|change io events\n**Epoll::CTL_DEL**|delete in interest list\n\n## Event flags\n\nevent flags|ctl|wait|description\n---|---|---|---\n**Epoll::IN**|o|o|readable\n**Epoll::PRI**|o|o|high priority read\n**Epoll::HUP**|o|o|peer socket was shutdown\n**Epoll::OUT**|o|o|writable\n**Epoll::ET**|o|x|use edge trigger\n**Epoll::ONESHOT**|o|x|auto watching stop when notified(but stay in list)\n**Epoll::ERR**|x|o|raise error\n**Epoll::HUP**|x|o|raise hang up\n\nsee also **man epoll(7)**\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'epoll'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install epoll\n\n# Pro Tips\n\n- Support call without GVL in CRuby (use rb\\_thread\\_call\\_without\\_gvl())\n- Close on exec flag set by default if you can use (use epoll_create1(EPOLL_CLOEXEC))\n- Epoll#wait max return array size is 256 on one time (of course, overflowing and then carried next)\n\n# Fork Me !\n\nThis is experimental implementation.\nI'm waiting for your idea and Pull Request !\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksss%2Fepoll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fksss%2Fepoll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksss%2Fepoll/lists"}