Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3
LightIO is a userland implemented green thread library for ruby
License
socketry/lightio
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
LightIO provides green thread to ruby. Like Golang's goroutine, or Crystal's fiber. In LightIO it is called beam.
Example:
require'lightio'start=Time.nowbeams=1000.times.mapdo# LightIO::Beam is green-thread, use it instead ThreadLightIO::Beam.newdo# do some io operations in beamLightIO.sleep(1)endendbeams.each(&:join)seconds=Time.now -startputs"1000 beams take#{seconds -1} seconds to create"
LightIO ship ruby stdlib compatible library underLightIO orLightIO::Library namespace,these libraries provide the ability to schedule LightIO beams when IO operations occur.
LightIO also provide a monkey patch, it replaces rubyThread withLightIO::Thread, and also replacesIO related classes.
Example:
require'lightio'# apply monkey patch at beginningLightIO::Monkey.patch_all!require'net/http'host='github.com'port=443start=Time.now10.times.mapdoThread.newdoNet::HTTP.start(host,port,use_ssl:true)do |http|res=http.request_get('/ping')pres.codeendendend.each(&:join)puts"#{Time.now -start} seconds"
SeeExamples for detail.
In fact ruby core team already plan to implementThread::Green in core language, seehttps://bugs.ruby-lang.org/issues/13618
It means if ruby implementedThread::Green, this library has no reason to exist.But 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.
SeeWiki andRoadmap to get more information.
LightIO is build uponnio4r. Get heavily inspired bygevent,async-io.
Add this line to your application's Gemfile:
gem'lightio'
And then execute:
$ bundleOr install it yourself as:
$ gem install lightioPlease see LightIO Wiki for more information.
The following documentations is also usable:
https://groups.google.com/group/lightio
After checking out the repo, runbin/setup to install dependencies. Then, runrake spec to run the tests. You can also runbin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, runbundle exec rake install. To release a new version, update the version number inversion.rb, and then runbundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the.gem file torubygems.org.
Bug reports and pull requests are welcome on GitHub athttps://github.com/jjyr/lightio. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to theContributor Covenant code of conduct.
The gem is available as open source under the terms of theMIT License.
Copyright, 2017-2018, byJiang Jinyang
Everyone interacting in the Lightio project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow thecode of conduct.
About
LightIO is a userland implemented green thread library for ruby
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.