Libuv FFI bindings for Ruby
Libuv is a cross platform asynchronous IO implementation that powers NodeJS. It supports sockets, both UDP and TCP, filesystem watch, TTY, Pipes and other asynchronous primitives like timer, check, prepare and idle.
The Libuv gem contains Libuv and a Ruby wrapper that implements pipelined promises for asynchronous flow control
Usage
Create a new libuv loop or use a default one
require 'libuv'
loop = Libuv::Loop.default
# or
# loop = Libuv::Loop.new
loop.run do
timer = loop.timer do
puts "5 seconds passed"
timer.close
loop.stop
end
timer.catch do |error|
puts "error with timer: #{error}"
end
timer.finally do
puts "timer handle was closed"
end
timer.start(5000)
end
Check out the yard documentation
Installation
gem install libuv
or
git clone https://github.com/cotag/libuv.git
cd libuv
bundle install
rake compile
Prerequisites
- The installation requires subversion to be installed on your system and available on the PATH
- Windows users will require a copy of Visual Studio 2010 or later. Visual Studio Express works fine.
or
- setting the environmental variable
USE_GLOBAL_LIBUV
will prevent compiling the packaged version.- if you have a compatible
libuv.(so | dylib | dll)
on the PATH already
- if you have a compatible
Libuv features supported
- TCP (with TLS support)
- UDP
- TTY
- Pipe
- Timer
- Prepare
- Check
- Idle
- Signals
- Async callbacks
- Async DNS Resolution
- Filesystem Events
- Filesystem manipulation
- File manipulation
- Errors
- Work queue (thread pool)