libuv 0.11.22 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +19 -17
- data/.gitmodules +3 -3
- data/.rspec +1 -1
- data/.travis.yml +16 -16
- data/Gemfile +4 -4
- data/LICENSE +23 -23
- data/README.md +89 -89
- data/Rakefile +31 -31
- data/lib/libuv.rb +54 -54
- data/lib/libuv/async.rb +47 -47
- data/lib/libuv/check.rb +55 -55
- data/lib/libuv/dns.rb +85 -85
- data/lib/libuv/error.rb +78 -74
- data/lib/libuv/ext/ext.rb +260 -258
- data/lib/libuv/ext/platform/darwin_x64.rb +23 -23
- data/lib/libuv/ext/platform/linux.rb +7 -7
- data/lib/libuv/ext/platform/unix.rb +29 -29
- data/lib/libuv/ext/platform/windows.rb +40 -40
- data/lib/libuv/ext/tasks.rb +31 -31
- data/lib/libuv/ext/tasks/mac.rb +23 -23
- data/lib/libuv/ext/tasks/unix.rb +23 -23
- data/lib/libuv/ext/tasks/win.rb +14 -14
- data/lib/libuv/ext/types.rb +238 -238
- data/lib/libuv/file.rb +281 -269
- data/lib/libuv/filesystem.rb +232 -232
- data/lib/libuv/fs_event.rb +31 -31
- data/lib/libuv/handle.rb +85 -85
- data/lib/libuv/idle.rb +56 -56
- data/lib/libuv/loop.rb +412 -412
- data/lib/libuv/mixins/assertions.rb +23 -23
- data/lib/libuv/mixins/fs_checks.rb +60 -58
- data/lib/libuv/mixins/listener.rb +34 -34
- data/lib/libuv/mixins/net.rb +40 -40
- data/lib/libuv/mixins/resource.rb +27 -27
- data/lib/libuv/mixins/stream.rb +153 -154
- data/lib/libuv/pipe.rb +184 -203
- data/lib/libuv/prepare.rb +56 -56
- data/lib/libuv/signal.rb +51 -51
- data/lib/libuv/tcp.rb +334 -334
- data/lib/libuv/timer.rb +85 -85
- data/lib/libuv/tty.rb +37 -37
- data/lib/libuv/udp.rb +240 -240
- data/lib/libuv/version.rb +3 -3
- data/lib/libuv/work.rb +75 -75
- data/libuv.gemspec +56 -56
- data/spec/async_spec.rb +61 -60
- data/spec/cpu_spec.rb +10 -10
- data/spec/defer_spec.rb +980 -980
- data/spec/dns_spec.rb +96 -90
- data/spec/filesystem_spec.rb +270 -261
- data/spec/idle_spec.rb +56 -56
- data/spec/pipe_spec.rb +160 -160
- data/spec/tcp_spec.rb +271 -267
- metadata +64 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ee9ba6ad1a238c617bdb54fdd81451500eaae87
|
4
|
+
data.tar.gz: 72f9ae6051012702edfd3883e13273af283165f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a126cb1c11fbd004203fae6639a8fb487dbaac5b6261c318111bae0bac60441407c37847fa81022ae16456f7d94d2893d0a4af4b952b7fd9086bb9cacf1f3902
|
7
|
+
data.tar.gz: 5a665a96dd8f166e3f4c8787028ddccf567eb34491b5236018b46b32b555e64326a6dc0eb1f455400b8006f8628205674cc35a41f1e497ae37e0a9c38c094a28
|
data/.gitignore
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
*.sw?
|
2
|
-
.DS_Store
|
3
|
-
coverage
|
4
|
-
rdoc
|
5
|
-
html
|
6
|
-
pkg
|
7
|
-
doc
|
8
|
-
tmp
|
9
|
-
rerun.txt
|
10
|
-
Gemfile.lock
|
11
|
-
.bundle
|
12
|
-
.idea
|
13
|
-
*.rbc
|
14
|
-
.yardoc
|
15
|
-
bin
|
16
|
-
Gemfile-custom
|
17
|
-
ext/*
|
1
|
+
*.sw?
|
2
|
+
.DS_Store
|
3
|
+
coverage
|
4
|
+
rdoc
|
5
|
+
html
|
6
|
+
pkg
|
7
|
+
doc
|
8
|
+
tmp
|
9
|
+
rerun.txt
|
10
|
+
Gemfile.lock
|
11
|
+
.bundle
|
12
|
+
.idea
|
13
|
+
*.rbc
|
14
|
+
.yardoc
|
15
|
+
bin
|
16
|
+
Gemfile-custom
|
17
|
+
ext/*
|
18
|
+
|
19
|
+
*.gem
|
data/.gitmodules
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
[submodule "ext/libuv"]
|
2
|
-
path = ext/libuv
|
3
|
-
url = https://github.com/joyent/libuv.git
|
1
|
+
[submodule "ext/libuv"]
|
2
|
+
path = ext/libuv
|
3
|
+
url = https://github.com/joyent/libuv.git
|
data/.rspec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--format progress
|
1
|
+
--format progress
|
data/.travis.yml
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- "1.9.3"
|
4
|
-
- "2.0.0"
|
5
|
-
- ruby-head
|
6
|
-
- rbx-2.2.1
|
7
|
-
- jruby-head
|
8
|
-
branches:
|
9
|
-
only:
|
10
|
-
- master
|
11
|
-
before_install:
|
12
|
-
- sudo apt-get install subversion
|
13
|
-
- git submodule update --init --recursive
|
14
|
-
- echo "yes" | gem uninstall ffi -a
|
15
|
-
before_script:
|
16
|
-
- rake compile
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- "1.9.3"
|
4
|
+
- "2.0.0"
|
5
|
+
- ruby-head
|
6
|
+
- rbx-2.2.1
|
7
|
+
- jruby-head
|
8
|
+
branches:
|
9
|
+
only:
|
10
|
+
- master
|
11
|
+
before_install:
|
12
|
+
- sudo apt-get install subversion
|
13
|
+
- git submodule update --init --recursive
|
14
|
+
- echo "yes" | gem uninstall ffi -a
|
15
|
+
before_script:
|
16
|
+
- rake compile
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
gemspec
|
3
|
-
|
4
|
-
gem "rubysl", :platform => :rbx
|
1
|
+
source "https://rubygems.org"
|
2
|
+
gemspec
|
3
|
+
|
4
|
+
gem "rubysl", :platform => :rbx
|
data/LICENSE
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
Copyright (c) 2004-2013 Cotag Media
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is furnished
|
8
|
-
to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
11
|
-
copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
20
|
-
|
21
|
-
===
|
22
|
-
|
23
|
-
This license applies to all parts of uvrb (Ruby FFI bindings for libuv only)
|
1
|
+
Copyright (c) 2004-2013 Cotag Media
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is furnished
|
8
|
+
to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
20
|
+
|
21
|
+
===
|
22
|
+
|
23
|
+
This license applies to all parts of uvrb (Ruby FFI bindings for libuv only)
|
24
24
|
Libuv itself [is using Node license](https://github.com/joyent/libuv/blob/master/LICENSE)
|
data/README.md
CHANGED
@@ -1,89 +1,89 @@
|
|
1
|
-
# Libuv FFI bindings for Ruby
|
2
|
-
|
3
|
-
[![Build Status](https://travis-ci.org/cotag/libuv.png?branch=master)](https://travis-ci.org/cotag/libuv)
|
4
|
-
|
5
|
-
[Libuv](https://github.com/joyent/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.
|
6
|
-
|
7
|
-
The Libuv gem contains Libuv and a Ruby wrapper that implements [pipelined promises](http://en.wikipedia.org/wiki/Futures_and_promises#Promise_pipelining) for asynchronous flow control
|
8
|
-
|
9
|
-
## Usage
|
10
|
-
|
11
|
-
Create a new libuv loop or use a default one
|
12
|
-
|
13
|
-
```ruby
|
14
|
-
require 'libuv'
|
15
|
-
|
16
|
-
loop = Libuv::Loop.default
|
17
|
-
# or
|
18
|
-
# loop = Libuv::Loop.new
|
19
|
-
|
20
|
-
loop.run do
|
21
|
-
timer = loop.timer do
|
22
|
-
puts "5 seconds passed"
|
23
|
-
timer.close
|
24
|
-
loop.stop
|
25
|
-
end
|
26
|
-
timer.catch do |error|
|
27
|
-
puts "error with timer: #{error}"
|
28
|
-
end
|
29
|
-
timer.finally do
|
30
|
-
puts "timer handle was closed"
|
31
|
-
end
|
32
|
-
timer.start(5000)
|
33
|
-
end
|
34
|
-
```
|
35
|
-
|
36
|
-
Check out the [yard documentation](http://rubydoc.info/gems/libuv/Libuv/Loop)
|
37
|
-
|
38
|
-
|
39
|
-
## Installation
|
40
|
-
|
41
|
-
```shell
|
42
|
-
gem install libuv
|
43
|
-
```
|
44
|
-
|
45
|
-
or
|
46
|
-
|
47
|
-
```shell
|
48
|
-
git clone https://github.com/cotag/libuv.git
|
49
|
-
cd libuv
|
50
|
-
bundle install
|
51
|
-
rake compile
|
52
|
-
```
|
53
|
-
|
54
|
-
### Prerequisites
|
55
|
-
|
56
|
-
* The installation requires [subversion](http://subversion.apache.org/packages.html) to be installed on your system and available on the PATH
|
57
|
-
* The installation also requires [python 2.x](http://www.python.org/getit/) to be installed and available on the PATH
|
58
|
-
* setting the environmental variable `USE_GLOBAL_LIBUV` will prevent compiling the packaged version.
|
59
|
-
* if you have a compatible `libuv.(so | dylib | dll)` on the PATH already
|
60
|
-
|
61
|
-
Windows users will additionally require:
|
62
|
-
|
63
|
-
- A copy of Visual Studio 2010 or later. [Visual Studio Express](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products) works fine.
|
64
|
-
- A copy of [OpenSSL](http://slproweb.com/products/Win32OpenSSL.html) matching the installed ruby (x86 / x64)
|
65
|
-
- with the environmental variable `OPENSSL_CONF` Set `OPENSSL_CONF=X:\path_to\OpenSSL\bin\openssl.cfg`
|
66
|
-
- If using jRuby then [GCC](http://win-builds.org/stable/) is also required
|
67
|
-
- Setup the paths as described on the gcc page
|
68
|
-
- Add required environmental variable `set LIBRARY_PATH=X:\win-builds-64\lib;X:\win-builds-64\x86_64-w64-mingw32\lib`
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
## Libuv features supported
|
73
|
-
|
74
|
-
* TCP (with TLS support)
|
75
|
-
* UDP
|
76
|
-
* TTY
|
77
|
-
* Pipes
|
78
|
-
* Timer
|
79
|
-
* Prepare
|
80
|
-
* Check
|
81
|
-
* Idle
|
82
|
-
* Signals
|
83
|
-
* Async callbacks
|
84
|
-
* Async DNS Resolution
|
85
|
-
* Filesystem Events
|
86
|
-
* Filesystem manipulation
|
87
|
-
* File manipulation
|
88
|
-
* Errors (with a catch-all fallback for anything unhandled on the event loop)
|
89
|
-
* Work queue (thread pool)
|
1
|
+
# Libuv FFI bindings for Ruby
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/cotag/libuv.png?branch=master)](https://travis-ci.org/cotag/libuv)
|
4
|
+
|
5
|
+
[Libuv](https://github.com/joyent/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.
|
6
|
+
|
7
|
+
The Libuv gem contains Libuv and a Ruby wrapper that implements [pipelined promises](http://en.wikipedia.org/wiki/Futures_and_promises#Promise_pipelining) for asynchronous flow control
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Create a new libuv loop or use a default one
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
require 'libuv'
|
15
|
+
|
16
|
+
loop = Libuv::Loop.default
|
17
|
+
# or
|
18
|
+
# loop = Libuv::Loop.new
|
19
|
+
|
20
|
+
loop.run do
|
21
|
+
timer = loop.timer do
|
22
|
+
puts "5 seconds passed"
|
23
|
+
timer.close
|
24
|
+
loop.stop
|
25
|
+
end
|
26
|
+
timer.catch do |error|
|
27
|
+
puts "error with timer: #{error}"
|
28
|
+
end
|
29
|
+
timer.finally do
|
30
|
+
puts "timer handle was closed"
|
31
|
+
end
|
32
|
+
timer.start(5000)
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
Check out the [yard documentation](http://rubydoc.info/gems/libuv/Libuv/Loop)
|
37
|
+
|
38
|
+
|
39
|
+
## Installation
|
40
|
+
|
41
|
+
```shell
|
42
|
+
gem install libuv
|
43
|
+
```
|
44
|
+
|
45
|
+
or
|
46
|
+
|
47
|
+
```shell
|
48
|
+
git clone https://github.com/cotag/libuv.git
|
49
|
+
cd libuv
|
50
|
+
bundle install
|
51
|
+
rake compile
|
52
|
+
```
|
53
|
+
|
54
|
+
### Prerequisites
|
55
|
+
|
56
|
+
* The installation requires [subversion](http://subversion.apache.org/packages.html) to be installed on your system and available on the PATH
|
57
|
+
* The installation also requires [python 2.x](http://www.python.org/getit/) to be installed and available on the PATH
|
58
|
+
* setting the environmental variable `USE_GLOBAL_LIBUV` will prevent compiling the packaged version.
|
59
|
+
* if you have a compatible `libuv.(so | dylib | dll)` on the PATH already
|
60
|
+
|
61
|
+
Windows users will additionally require:
|
62
|
+
|
63
|
+
- A copy of Visual Studio 2010 or later. [Visual Studio Express](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products) works fine.
|
64
|
+
- A copy of [OpenSSL](http://slproweb.com/products/Win32OpenSSL.html) matching the installed ruby (x86 / x64)
|
65
|
+
- with the environmental variable `OPENSSL_CONF` Set `OPENSSL_CONF=X:\path_to\OpenSSL\bin\openssl.cfg`
|
66
|
+
- If using jRuby then [GCC](http://win-builds.org/stable/) is also required
|
67
|
+
- Setup the paths as described on the gcc page
|
68
|
+
- Add required environmental variable `set LIBRARY_PATH=X:\win-builds-64\lib;X:\win-builds-64\x86_64-w64-mingw32\lib`
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
## Libuv features supported
|
73
|
+
|
74
|
+
* TCP (with TLS support)
|
75
|
+
* UDP
|
76
|
+
* TTY
|
77
|
+
* Pipes
|
78
|
+
* Timer
|
79
|
+
* Prepare
|
80
|
+
* Check
|
81
|
+
* Idle
|
82
|
+
* Signals
|
83
|
+
* Async callbacks
|
84
|
+
* Async DNS Resolution
|
85
|
+
* Filesystem Events
|
86
|
+
* Filesystem manipulation
|
87
|
+
* File manipulation
|
88
|
+
* Errors (with a catch-all fallback for anything unhandled on the event loop)
|
89
|
+
* Work queue (thread pool)
|
data/Rakefile
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rspec/core/rake_task' # testing framework
|
3
|
-
require 'yard' # yard documentation
|
4
|
-
require 'ffi' # loads the extension
|
5
|
-
require 'rake/clean' # for the :clobber rake task
|
6
|
-
require File.expand_path('../lib/libuv/ext/tasks', __FILE__) # platform specific rake tasks used by compile
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# By default we don't run network tests
|
11
|
-
task :default => :limited_spec
|
12
|
-
RSpec::Core::RakeTask.new(:limited_spec) do |t|
|
13
|
-
# Exclude network tests
|
14
|
-
t.rspec_opts = "--tag ~network"
|
15
|
-
end
|
16
|
-
RSpec::Core::RakeTask.new(:spec)
|
17
|
-
|
18
|
-
|
19
|
-
desc "Run all tests"
|
20
|
-
task :test => [:spec]
|
21
|
-
|
22
|
-
|
23
|
-
YARD::Rake::YardocTask.new do |t|
|
24
|
-
t.files = ['lib/**/*.rb', '-', 'ext/README.md', 'README.md']
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
desc "Compile libuv from submodule"
|
29
|
-
task :compile => ["ext/libuv.#{FFI::Platform::LIBSUFFIX}"]
|
30
|
-
|
31
|
-
CLOBBER.include("ext/libuv.#{FFI::Platform::LIBSUFFIX}")
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec/core/rake_task' # testing framework
|
3
|
+
require 'yard' # yard documentation
|
4
|
+
require 'ffi' # loads the extension
|
5
|
+
require 'rake/clean' # for the :clobber rake task
|
6
|
+
require File.expand_path('../lib/libuv/ext/tasks', __FILE__) # platform specific rake tasks used by compile
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# By default we don't run network tests
|
11
|
+
task :default => :limited_spec
|
12
|
+
RSpec::Core::RakeTask.new(:limited_spec) do |t|
|
13
|
+
# Exclude network tests
|
14
|
+
t.rspec_opts = "--tag ~network"
|
15
|
+
end
|
16
|
+
RSpec::Core::RakeTask.new(:spec)
|
17
|
+
|
18
|
+
|
19
|
+
desc "Run all tests"
|
20
|
+
task :test => [:spec]
|
21
|
+
|
22
|
+
|
23
|
+
YARD::Rake::YardocTask.new do |t|
|
24
|
+
t.files = ['lib/**/*.rb', '-', 'ext/README.md', 'README.md']
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
desc "Compile libuv from submodule"
|
29
|
+
task :compile => ["ext/libuv.#{FFI::Platform::LIBSUFFIX}"]
|
30
|
+
|
31
|
+
CLOBBER.include("ext/libuv.#{FFI::Platform::LIBSUFFIX}")
|
data/lib/libuv.rb
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
require 'ffi'
|
3
|
-
|
4
|
-
module Libuv
|
5
|
-
require 'libuv/ext/ext' # The libuv ffi ext
|
6
|
-
require 'libuv/error' # List of errors (matching those in uv.h)
|
7
|
-
require 'libuv/q' # The promise library
|
8
|
-
|
9
|
-
require 'libuv/mixins/assertions' # Common code to check arguments
|
10
|
-
require 'libuv/mixins/fs_checks' # Common code to check file system results
|
11
|
-
require 'libuv/mixins/resource' # Common code to check for errors
|
12
|
-
require 'libuv/mixins/listener' # Common callback code
|
13
|
-
require 'libuv/mixins/stream' # For all libuv streams (tcp, pipes, tty)
|
14
|
-
require 'libuv/mixins/net' # Common functions for tcp and udp
|
15
|
-
|
16
|
-
# -- The classes required for a loop instance --
|
17
|
-
require 'libuv/handle' # Base class for most libuv functionality
|
18
|
-
require 'libuv/async' # Provide a threadsafe way to signal the event loop
|
19
|
-
require 'libuv/timer' # High resolution timer
|
20
|
-
require 'libuv/loop' # The libuv reactor or event loop
|
21
|
-
# --
|
22
|
-
|
23
|
-
require 'libuv/filesystem' # Async directory manipulation
|
24
|
-
require 'libuv/fs_event' # Notifies of changes to files and folders as they occur
|
25
|
-
require 'libuv/prepare' # Called at the end of a loop cycle
|
26
|
-
require 'libuv/signal' # Used to handle OS signals
|
27
|
-
require 'libuv/check' # Called before processing events on the loop
|
28
|
-
require 'libuv/file' # Async file reading and writing
|
29
|
-
require 'libuv/idle' # Called when there are no events to process
|
30
|
-
require 'libuv/work' # Provide work to be completed on another thread (thread pool)
|
31
|
-
require 'libuv/udp' # Communicate over UDP
|
32
|
-
require 'libuv/dns' # Async DNS lookup
|
33
|
-
|
34
|
-
# Streams
|
35
|
-
require 'libuv/pipe' # Communicate over Pipes
|
36
|
-
require 'libuv/tcp' # Communicate over TCP
|
37
|
-
require 'libuv/tty' # Terminal output
|
38
|
-
|
39
|
-
|
40
|
-
# Returns the number of CPU cores on the host platform
|
41
|
-
#
|
42
|
-
# @return [Fixnum, nil] representing the number of CPU cores or nil if failed
|
43
|
-
def self.cpu_count
|
44
|
-
cpu_info = FFI::MemoryPointer.new(:pointer)
|
45
|
-
cpu_count = FFI::MemoryPointer.new(:int)
|
46
|
-
if ::Libuv::Ext.cpu_info(cpu_info, cpu_count) >= 0
|
47
|
-
count = cpu_count.read_int
|
48
|
-
::Libuv::Ext.free_cpu_info(cpu_info.read_pointer, count)
|
49
|
-
return count
|
50
|
-
else
|
51
|
-
return nil
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
1
|
+
require 'forwardable'
|
2
|
+
require 'ffi'
|
3
|
+
|
4
|
+
module Libuv
|
5
|
+
require 'libuv/ext/ext' # The libuv ffi ext
|
6
|
+
require 'libuv/error' # List of errors (matching those in uv.h)
|
7
|
+
require 'libuv/q' # The promise library
|
8
|
+
|
9
|
+
require 'libuv/mixins/assertions' # Common code to check arguments
|
10
|
+
require 'libuv/mixins/fs_checks' # Common code to check file system results
|
11
|
+
require 'libuv/mixins/resource' # Common code to check for errors
|
12
|
+
require 'libuv/mixins/listener' # Common callback code
|
13
|
+
require 'libuv/mixins/stream' # For all libuv streams (tcp, pipes, tty)
|
14
|
+
require 'libuv/mixins/net' # Common functions for tcp and udp
|
15
|
+
|
16
|
+
# -- The classes required for a loop instance --
|
17
|
+
require 'libuv/handle' # Base class for most libuv functionality
|
18
|
+
require 'libuv/async' # Provide a threadsafe way to signal the event loop
|
19
|
+
require 'libuv/timer' # High resolution timer
|
20
|
+
require 'libuv/loop' # The libuv reactor or event loop
|
21
|
+
# --
|
22
|
+
|
23
|
+
require 'libuv/filesystem' # Async directory manipulation
|
24
|
+
require 'libuv/fs_event' # Notifies of changes to files and folders as they occur
|
25
|
+
require 'libuv/prepare' # Called at the end of a loop cycle
|
26
|
+
require 'libuv/signal' # Used to handle OS signals
|
27
|
+
require 'libuv/check' # Called before processing events on the loop
|
28
|
+
require 'libuv/file' # Async file reading and writing
|
29
|
+
require 'libuv/idle' # Called when there are no events to process
|
30
|
+
require 'libuv/work' # Provide work to be completed on another thread (thread pool)
|
31
|
+
require 'libuv/udp' # Communicate over UDP
|
32
|
+
require 'libuv/dns' # Async DNS lookup
|
33
|
+
|
34
|
+
# Streams
|
35
|
+
require 'libuv/pipe' # Communicate over Pipes
|
36
|
+
require 'libuv/tcp' # Communicate over TCP
|
37
|
+
require 'libuv/tty' # Terminal output
|
38
|
+
|
39
|
+
|
40
|
+
# Returns the number of CPU cores on the host platform
|
41
|
+
#
|
42
|
+
# @return [Fixnum, nil] representing the number of CPU cores or nil if failed
|
43
|
+
def self.cpu_count
|
44
|
+
cpu_info = FFI::MemoryPointer.new(:pointer)
|
45
|
+
cpu_count = FFI::MemoryPointer.new(:int)
|
46
|
+
if ::Libuv::Ext.cpu_info(cpu_info, cpu_count) >= 0
|
47
|
+
count = cpu_count.read_int
|
48
|
+
::Libuv::Ext.free_cpu_info(cpu_info.read_pointer, count)
|
49
|
+
return count
|
50
|
+
else
|
51
|
+
return nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|