All Projects → socketry → Lightio

socketry / Lightio

Licence: mit
LightIO is a userland implemented green thread library for ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Lightio

Java Concurrency Examples
Java Concurrency/Multithreading Tutorial with Examples for Dummies
Stars: ✭ 173 (+4.85%)
Mutual labels:  concurrency, multithreading, thread
YACLib
Yet Another Concurrency Library
Stars: ✭ 193 (+16.97%)
Mutual labels:  thread, concurrency, fiber
Sobjectizer
An implementation of Actor, Publish-Subscribe, and CSP models in one rather small C++ framework. With performance, quality, and stability proved by years in the production.
Stars: ✭ 172 (+4.24%)
Mutual labels:  concurrency, multithreading, thread
theater
Actor framework for Dart. This package makes it easier to work with isolates, create clusters of isolates.
Stars: ✭ 29 (-82.42%)
Mutual labels:  thread, concurrency, multithreading
Asks
Async requests-like httplib for python.
Stars: ✭ 429 (+160%)
Mutual labels:  async, concurrency, io
Swiftcoroutine
Swift coroutines for iOS, macOS and Linux.
Stars: ✭ 690 (+318.18%)
Mutual labels:  async, multithreading, thread
Smol
A small and fast async runtime for Rust
Stars: ✭ 2,206 (+1236.97%)
Mutual labels:  async, concurrency, networking
Trio
Trio – a friendly Python library for async concurrency and I/O
Stars: ✭ 4,404 (+2569.09%)
Mutual labels:  async, io, networking
Actix Net
A collection of lower-level libraries for composable network services.
Stars: ✭ 415 (+151.52%)
Mutual labels:  async, multithreading, networking
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (+213.33%)
Mutual labels:  concurrency, multithreading, thread
Vibe.d
Official vibe.d development
Stars: ✭ 1,043 (+532.12%)
Mutual labels:  async, concurrency, networking
Drone
CLI utility for Drone, an Embedded Operating System.
Stars: ✭ 114 (-30.91%)
Mutual labels:  async, concurrency
Nuclei
Proactive IO & Runtime system
Stars: ✭ 113 (-31.52%)
Mutual labels:  async, io
Popol
Minimal non-blocking I/O for Rust
Stars: ✭ 118 (-28.48%)
Mutual labels:  async, networking
Java Concurrent Programming
📓 《实战Java 高并发程序设计》笔记和源码整理
Stars: ✭ 162 (-1.82%)
Mutual labels:  concurrency, thread
Ws Machine
WS-Machine is a websocket finite state machine for client websocket connections (Go)
Stars: ✭ 110 (-33.33%)
Mutual labels:  async, networking
Socket
Non-blocking socket and TLS functionality for PHP based on Amp.
Stars: ✭ 122 (-26.06%)
Mutual labels:  async, io
Minicoro
Single header asymmetric stackful cross-platform coroutine library in pure C.
Stars: ✭ 164 (-0.61%)
Mutual labels:  async, fiber
Mioco
[no longer maintained] Scalable, coroutine-based, fibers/green-threads for Rust. (aka MIO COroutines).
Stars: ✭ 125 (-24.24%)
Mutual labels:  async, io
Important Java Concepts
🚀 Complete Java - A to Z ║ 📚 Notes and Programs of all Important Concepts of Java - OOPS, Data Structures, Algorithms, Design Patterns & Development + Kotlin + Android 🔥
Stars: ✭ 135 (-18.18%)
Mutual labels:  concurrency, multithreading

LightIO

Gem Version Build Status Coverage Status MIT licensed Gitter

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.now

beams = 1000.times.map do
  # LightIO::Beam is green-thread, use it instead Thread
  LightIO::Beam.new do
    # do some io operations in beam
    LightIO.sleep(1)
  end
end

beams.each(&:join)
seconds = Time.now - start
puts "1000 beams take #{seconds - 1} seconds to create"

LightIO ship ruby stdlib compatible library under LightIO or LightIO::Library namespace, these libraries provide the ability to schedule LightIO beams when IO operations occur.

LightIO also provide a monkey patch, it replaces ruby Thread with LightIO::Thread, and also replaces IO related classes.

Example:

require 'lightio'
# apply monkey patch at beginning
LightIO::Monkey.patch_all!

require 'net/http'

host = 'github.com'
port = 443

start = Time.now

10.times.map do
  Thread.new do
    Net::HTTP.start(host, port, use_ssl: true) do |http|
      res = http.request_get('/ping')
      p res.code
    end
  end
end.each(&:join)

puts "#{Time.now - start} seconds"

See Examples for detail.

You Should Know

In fact ruby core team already plan to implement Thread::Green in core language, see https://bugs.ruby-lang.org/issues/13618

It means if ruby implemented Thread::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.

See Wiki and Roadmap to get more information.

LightIO is build upon nio4r. Get heavily inspired by gevent, async-io.

Installation

Add this line to your application's Gemfile:

gem 'lightio'

And then execute:

$ bundle

Or install it yourself as:

$ gem install lightio

Documentation

Please see LightIO Wiki for more information.

The following documentations is also usable:

Discussion

https://groups.google.com/group/lightio

Development

After 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.

To 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.

Contributing

Bug 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 code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Copyright, 2017-2018, by Jiang Jinyang

Code of Conduct

Everyone interacting in the Lightio project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].