{"id":19316006,"url":"https://github.com/socketry/lightio","last_synced_at":"2025-04-22T16:32:58.257Z","repository":{"id":49878454,"uuid":"112482106","full_name":"socketry/lightio","owner":"socketry","description":"LightIO is a userland implemented green thread library for ruby","archived":false,"fork":false,"pushed_at":"2021-06-09T07:11:48.000Z","size":197,"stargazers_count":162,"open_issues_count":7,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-31T13:25:32.759Z","etag":null,"topics":["async","concurrency","eventloop","fiber","green","io","multithreading","networking","ruby","thread"],"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/socketry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-29T13:59:12.000Z","updated_at":"2024-10-18T08:07:49.000Z","dependencies_parsed_at":"2022-08-20T13:00:14.836Z","dependency_job_id":null,"html_url":"https://github.com/socketry/lightio","commit_stats":null,"previous_names":["jjyr/lightio"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Flightio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Flightio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Flightio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/socketry%2Flightio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/socketry","download_url":"https://codeload.github.com/socketry/lightio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223900219,"owners_count":17222028,"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":["async","concurrency","eventloop","fiber","green","io","multithreading","networking","ruby","thread"],"created_at":"2024-11-10T01:09:24.709Z","updated_at":"2024-11-10T01:09:25.270Z","avatar_url":"https://github.com/socketry.png","language":"Ruby","readme":"# LightIO\n\n\n[![Gem Version](https://badge.fury.io/rb/lightio.svg)](http://rubygems.org/gems/lightio)\n[![Build Status](https://travis-ci.org/socketry/lightio.svg?branch=master)](https://travis-ci.org/socketry/lightio)\n[![Coverage Status](https://coveralls.io/repos/github/socketry/lightio/badge.svg?branch=master)](https://coveralls.io/github/socketry/lightio?branch=master)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jjyr/lightio/blob/master/LICENSE.txt)\n[![Gitter](https://badges.gitter.im/join.svg)](https://gitter.im/lightio-dev/Lobby)\n\nLightIO provides green thread to ruby. Like Golang's goroutine, or Crystal's fiber. In LightIO it is called beam.\n\nExample:\n\n``` ruby\nrequire 'lightio'\n\nstart = Time.now\n\nbeams = 1000.times.map do\n  # LightIO::Beam is green-thread, use it instead Thread\n  LightIO::Beam.new do\n    # do some io operations in beam\n    LightIO.sleep(1)\n  end\nend\n\nbeams.each(\u0026:join)\nseconds = Time.now - start\nputs \"1000 beams take #{seconds - 1} seconds to create\"\n\n```\n\n\nLightIO ship ruby stdlib compatible library under `LightIO` or `LightIO::Library` namespace,\nthese libraries provide the ability to schedule LightIO beams when IO operations occur.\n\n\nLightIO also provide a monkey patch, it replaces ruby `Thread` with `LightIO::Thread`, and also replaces `IO` related classes.\n\nExample:\n\n``` ruby\nrequire 'lightio'\n# apply monkey patch at beginning\nLightIO::Monkey.patch_all!\n\nrequire 'net/http'\n\nhost = 'github.com'\nport = 443\n\nstart = Time.now\n\n10.times.map do\n  Thread.new do\n    Net::HTTP.start(host, port, use_ssl: true) do |http|\n      res = http.request_get('/ping')\n      p res.code\n    end\n  end\nend.each(\u0026:join)\n\nputs \"#{Time.now - start} seconds\"\n\n```\n\nSee [Examples](/examples) for detail.\n\n### You Should Know\n\nIn fact ruby core team already plan to implement `Thread::Green` in core language, see https://bugs.ruby-lang.org/issues/13618\n\nIt means if ruby implemented `Thread::Green`, this library has no reason to exist.\nBut as a crazy userland implemented green thread library, it bring lots of fun to me, so I will continue to maintain it, and welcome to use.\n\n\nSee [Wiki](https://github.com/jjyr/lightio/wiki) and [Roadmap](https://github.com/jjyr/lightio/wiki/Current-status-and-roadmap) to get more information.\n\nLightIO is build upon [nio4r](https://github.com/socketry/nio4r). Get heavily inspired by [gevent](http://www.gevent.org/), [async-io](https://github.com/socketry/async-io).\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'lightio'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install lightio\n\n## Documentation\n\n[Please see LightIO Wiki](https://github.com/jjyr/lightio/wiki) for more information.\n\nThe following documentations is also usable:\n\n* [Basic usage](https://github.com/socketry/lightio/wiki/Basic-Usage)\n* [YARD documentation](http://www.rubydoc.info/github/socketry/lightio/master)\n* [Examples](/examples)\n\n## Discussion\n\nhttps://groups.google.com/group/lightio\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/jjyr/lightio. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\nCopyright, 2017-2018, by [Jiang Jinyang](http://justjjy.com/)\n\n## Code of Conduct\n\nEveryone interacting in the Lightio project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lightio/blob/master/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketry%2Flightio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsocketry%2Flightio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsocketry%2Flightio/lists"}