libuv 0.10.0 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -17
- data/.gitmodules +3 -3
- data/.rspec +1 -1
- data/.travis.yml +16 -16
- data/Gemfile +2 -2
- data/LICENSE +23 -23
- data/README.md +82 -73
- data/Rakefile +31 -31
- data/lib/libuv.rb +53 -34
- data/lib/libuv/async.rb +47 -33
- data/lib/libuv/check.rb +55 -48
- data/lib/libuv/error.rb +70 -70
- data/lib/libuv/ext/ext.rb +264 -256
- data/lib/libuv/ext/platform/darwin_x64.rb +12 -12
- data/lib/libuv/ext/platform/linux.rb +7 -7
- data/lib/libuv/ext/platform/unix.rb +13 -13
- data/lib/libuv/ext/platform/windows.rb +26 -26
- data/lib/libuv/ext/tasks.rb +27 -27
- 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 +11 -11
- data/lib/libuv/ext/types.rb +234 -229
- data/lib/libuv/file.rb +192 -0
- data/lib/libuv/filesystem.rb +233 -0
- data/lib/libuv/fs_event.rb +31 -31
- data/lib/libuv/handle.rb +85 -81
- data/lib/libuv/idle.rb +56 -49
- data/lib/libuv/loop.rb +338 -310
- data/lib/libuv/{assertions.rb → mixins/assertions.rb} +23 -23
- data/lib/libuv/mixins/fs_checks.rb +55 -0
- data/lib/libuv/{listener.rb → mixins/listener.rb} +34 -34
- data/lib/libuv/{net.rb → mixins/net.rb} +37 -37
- data/lib/libuv/{resource.rb → mixins/resource.rb} +27 -27
- data/lib/libuv/{stream.rb → mixins/stream.rb} +143 -123
- data/lib/libuv/pipe.rb +197 -97
- data/lib/libuv/prepare.rb +56 -49
- data/lib/libuv/q.rb +1 -1
- data/lib/libuv/signal.rb +51 -0
- data/lib/libuv/tcp.rb +204 -193
- data/lib/libuv/timer.rb +88 -75
- data/lib/libuv/tty.rb +37 -34
- data/lib/libuv/udp.rb +273 -255
- data/lib/libuv/version.rb +3 -3
- data/lib/libuv/work.rb +63 -61
- data/libuv.gemspec +54 -54
- data/spec/async_spec.rb +60 -60
- data/spec/cpu_spec.rb +10 -0
- data/spec/defer_spec.rb +980 -980
- data/spec/filesystem_spec.rb +119 -0
- data/spec/idle_spec.rb +56 -56
- data/spec/pipe_spec.rb +153 -148
- data/spec/tcp_spec.rb +203 -188
- metadata +73 -49
- checksums.yaml +0 -15
- data/lib/libuv/simple_async.rb +0 -28
data/spec/tcp_spec.rb
CHANGED
@@ -1,188 +1,203 @@
|
|
1
|
-
require 'libuv'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@
|
8
|
-
|
9
|
-
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@
|
13
|
-
|
14
|
-
@
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
#
|
57
|
-
@
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
@
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
@
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
@
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
@
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
@
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
1
|
+
require 'libuv'
|
2
|
+
require 'thread'
|
3
|
+
|
4
|
+
|
5
|
+
describe Libuv::TCP do
|
6
|
+
before :each do
|
7
|
+
@log = []
|
8
|
+
@general_failure = []
|
9
|
+
|
10
|
+
@loop = Libuv::Loop.new
|
11
|
+
@server = @loop.tcp
|
12
|
+
@client = @loop.tcp
|
13
|
+
@timeout = @loop.timer do
|
14
|
+
@loop.stop
|
15
|
+
@loop2.stop if @loop2
|
16
|
+
@general_failure << "test timed out"
|
17
|
+
end
|
18
|
+
@timeout.start(5000)
|
19
|
+
|
20
|
+
@loop.all(@server, @client, @timeout).catch do |reason|
|
21
|
+
@general_failure << reason.inspect
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
@pipefile = "/tmp/test-pipe.pipe"
|
26
|
+
|
27
|
+
begin
|
28
|
+
File.unlink(@pipefile)
|
29
|
+
rescue
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'basic client server' do
|
34
|
+
it "should send a ping and return a pong", :network => true do
|
35
|
+
@loop.run { |logger|
|
36
|
+
logger.progress do |level, errorid, error|
|
37
|
+
begin
|
38
|
+
p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
|
39
|
+
rescue Exception
|
40
|
+
p 'error in logger'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
@server.bind('127.0.0.1', 34567) do |server|
|
46
|
+
server.accept do |client|
|
47
|
+
client.progress do |data|
|
48
|
+
@log << data
|
49
|
+
|
50
|
+
client.write('pong')
|
51
|
+
end
|
52
|
+
client.start_read
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# catch errors
|
57
|
+
@server.catch do |reason|
|
58
|
+
@general_failure << reason.inspect
|
59
|
+
end
|
60
|
+
|
61
|
+
# start listening
|
62
|
+
@server.listen(1024)
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
# connect client to server
|
67
|
+
@client.connect('127.0.0.1', 34567) do |client|
|
68
|
+
client.progress do |data|
|
69
|
+
@log << data
|
70
|
+
|
71
|
+
@client.shutdown
|
72
|
+
end
|
73
|
+
|
74
|
+
@client.start_read
|
75
|
+
@client.write('ping')
|
76
|
+
end
|
77
|
+
|
78
|
+
# catch errors
|
79
|
+
@client.catch do |reason|
|
80
|
+
@general_failure << reason.inspect
|
81
|
+
end
|
82
|
+
|
83
|
+
# close the handle
|
84
|
+
@client.finally do
|
85
|
+
@server.close
|
86
|
+
@loop.stop
|
87
|
+
end
|
88
|
+
}
|
89
|
+
|
90
|
+
@general_failure.should == []
|
91
|
+
@log.should == ['ping', 'pong']
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should handle requests on different threads", :network => true do
|
96
|
+
@sync = Mutex.new
|
97
|
+
|
98
|
+
@loop.run { |logger|
|
99
|
+
logger.progress do |level, errorid, error|
|
100
|
+
begin
|
101
|
+
p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
|
102
|
+
rescue Exception
|
103
|
+
p 'error in logger'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
@remote = nil
|
109
|
+
@server.bind('127.0.0.1', 45678) do |server|
|
110
|
+
server.accept do |client|
|
111
|
+
@remote.write2(client)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# catch errors
|
116
|
+
@server.catch do |reason|
|
117
|
+
@general_failure << reason.inspect
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
@pipeserve = @loop.pipe(true)
|
122
|
+
@pipeserve.bind(@pipefile) do |connection|
|
123
|
+
connection.accept do |client|
|
124
|
+
@remote = client
|
125
|
+
|
126
|
+
# start listening on TCP server
|
127
|
+
@server.listen(1024)
|
128
|
+
|
129
|
+
# connect client to server
|
130
|
+
@client.connect('127.0.0.1', 45678) do |client|
|
131
|
+
client.progress do |data|
|
132
|
+
@sync.synchronize {
|
133
|
+
@log << data
|
134
|
+
}
|
135
|
+
@client.shutdown
|
136
|
+
end
|
137
|
+
|
138
|
+
@client.start_read
|
139
|
+
@client.write('ping')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# start listening
|
145
|
+
@pipeserve.listen(1024)
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
# catch errors
|
150
|
+
@client.catch do |reason|
|
151
|
+
@general_failure << reason.inspect
|
152
|
+
end
|
153
|
+
|
154
|
+
# close the handle
|
155
|
+
@client.finally do
|
156
|
+
@server.close
|
157
|
+
@pipeserve.close
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
Thread.new do
|
163
|
+
@loop2 = Libuv::Loop.new
|
164
|
+
@pipeclient = @loop2.pipe(true)
|
165
|
+
|
166
|
+
|
167
|
+
@loop2.run do |logger|
|
168
|
+
logger.progress do |level, errorid, error|
|
169
|
+
begin
|
170
|
+
p "Log called: #{level}: #{errorid}\n#{error.message}\n#{error.backtrace.join("\n")}\n"
|
171
|
+
rescue Exception
|
172
|
+
p 'error in logger'
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# connect client to server
|
177
|
+
@pipeclient.connect(@pipefile) do |client|
|
178
|
+
@pipeclient.progress do |data, connection|
|
179
|
+
connection.progress do |data|
|
180
|
+
@sync.synchronize {
|
181
|
+
@log << data
|
182
|
+
}
|
183
|
+
connection.write('pong')
|
184
|
+
end
|
185
|
+
connection.start_read
|
186
|
+
connection.finally do
|
187
|
+
@pipeclient.close
|
188
|
+
@loop2.stop
|
189
|
+
@loop.stop
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
@pipeclient.start_read2
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
}
|
198
|
+
|
199
|
+
@general_failure.should == []
|
200
|
+
@log.should == ['ping', 'pong']
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
metadata
CHANGED
@@ -1,86 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libuv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease:
|
5
|
+
version: 0.10.2
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Bulat Shakirzyanov
|
8
9
|
- Stephen von Takach
|
9
|
-
autorequire:
|
10
|
+
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
+
date: 2013-09-03 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: ffi
|
16
|
-
|
17
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
18
|
requirements:
|
18
|
-
- -
|
19
|
+
- - '>='
|
19
20
|
- !ruby/object:Gem::Version
|
20
21
|
version: '1.9'
|
21
|
-
|
22
|
-
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.9'
|
28
|
+
none: false
|
29
|
+
prerelease: false
|
30
|
+
type: :runtime
|
28
31
|
- !ruby/object:Gem::Dependency
|
29
32
|
name: thread_safe
|
30
|
-
|
33
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
34
|
requirements:
|
32
|
-
- -
|
35
|
+
- - '>='
|
33
36
|
- !ruby/object:Gem::Version
|
34
37
|
version: '0'
|
35
|
-
|
36
|
-
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirement: !ruby/object:Gem::Requirement
|
38
40
|
requirements:
|
39
|
-
- -
|
41
|
+
- - '>='
|
40
42
|
- !ruby/object:Gem::Version
|
41
43
|
version: '0'
|
44
|
+
none: false
|
45
|
+
prerelease: false
|
46
|
+
type: :runtime
|
42
47
|
- !ruby/object:Gem::Dependency
|
43
48
|
name: rspec
|
44
|
-
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
50
|
requirements:
|
46
|
-
- -
|
51
|
+
- - '>='
|
47
52
|
- !ruby/object:Gem::Version
|
48
53
|
version: '2.14'
|
49
|
-
|
50
|
-
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
52
56
|
requirements:
|
53
|
-
- -
|
57
|
+
- - '>='
|
54
58
|
- !ruby/object:Gem::Version
|
55
59
|
version: '2.14'
|
60
|
+
none: false
|
61
|
+
prerelease: false
|
62
|
+
type: :development
|
56
63
|
- !ruby/object:Gem::Dependency
|
57
64
|
name: rake
|
58
|
-
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
66
|
requirements:
|
60
|
-
- -
|
67
|
+
- - '>='
|
61
68
|
- !ruby/object:Gem::Version
|
62
69
|
version: '10.1'
|
63
|
-
|
64
|
-
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
66
72
|
requirements:
|
67
|
-
- -
|
73
|
+
- - '>='
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: '10.1'
|
76
|
+
none: false
|
77
|
+
prerelease: false
|
78
|
+
type: :development
|
70
79
|
- !ruby/object:Gem::Dependency
|
71
80
|
name: yard
|
72
|
-
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
82
|
requirements:
|
74
|
-
- -
|
83
|
+
- - '>='
|
75
84
|
- !ruby/object:Gem::Version
|
76
85
|
version: '0'
|
77
|
-
|
78
|
-
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
80
88
|
requirements:
|
81
|
-
- -
|
89
|
+
- - '>='
|
82
90
|
- !ruby/object:Gem::Version
|
83
91
|
version: '0'
|
92
|
+
none: false
|
93
|
+
prerelease: false
|
94
|
+
type: :development
|
84
95
|
description: An opinionated wrapper around libuv for Ruby
|
85
96
|
email:
|
86
97
|
- mallluhuct@gmail.com
|
@@ -101,7 +112,6 @@ files:
|
|
101
112
|
- ext/README.md
|
102
113
|
- ext/Rakefile
|
103
114
|
- lib/libuv.rb
|
104
|
-
- lib/libuv/assertions.rb
|
105
115
|
- lib/libuv/async.rb
|
106
116
|
- lib/libuv/check.rb
|
107
117
|
- lib/libuv/error.rb
|
@@ -115,18 +125,22 @@ files:
|
|
115
125
|
- lib/libuv/ext/tasks/unix.rb
|
116
126
|
- lib/libuv/ext/tasks/win.rb
|
117
127
|
- lib/libuv/ext/types.rb
|
128
|
+
- lib/libuv/file.rb
|
129
|
+
- lib/libuv/filesystem.rb
|
118
130
|
- lib/libuv/fs_event.rb
|
119
131
|
- lib/libuv/handle.rb
|
120
132
|
- lib/libuv/idle.rb
|
121
|
-
- lib/libuv/listener.rb
|
122
133
|
- lib/libuv/loop.rb
|
123
|
-
- lib/libuv/
|
134
|
+
- lib/libuv/mixins/assertions.rb
|
135
|
+
- lib/libuv/mixins/fs_checks.rb
|
136
|
+
- lib/libuv/mixins/listener.rb
|
137
|
+
- lib/libuv/mixins/net.rb
|
138
|
+
- lib/libuv/mixins/resource.rb
|
139
|
+
- lib/libuv/mixins/stream.rb
|
124
140
|
- lib/libuv/pipe.rb
|
125
141
|
- lib/libuv/prepare.rb
|
126
142
|
- lib/libuv/q.rb
|
127
|
-
- lib/libuv/
|
128
|
-
- lib/libuv/simple_async.rb
|
129
|
-
- lib/libuv/stream.rb
|
143
|
+
- lib/libuv/signal.rb
|
130
144
|
- lib/libuv/tcp.rb
|
131
145
|
- lib/libuv/timer.rb
|
132
146
|
- lib/libuv/tty.rb
|
@@ -135,7 +149,9 @@ files:
|
|
135
149
|
- lib/libuv/work.rb
|
136
150
|
- libuv.gemspec
|
137
151
|
- spec/async_spec.rb
|
152
|
+
- spec/cpu_spec.rb
|
138
153
|
- spec/defer_spec.rb
|
154
|
+
- spec/filesystem_spec.rb
|
139
155
|
- spec/idle_spec.rb
|
140
156
|
- spec/pipe_spec.rb
|
141
157
|
- spec/tcp_spec.rb
|
@@ -357,26 +373,34 @@ files:
|
|
357
373
|
homepage: https://github.com/cotag/libuv
|
358
374
|
licenses:
|
359
375
|
- MIT
|
360
|
-
|
361
|
-
post_install_message:
|
376
|
+
post_install_message:
|
362
377
|
rdoc_options: []
|
363
378
|
require_paths:
|
364
379
|
- lib
|
365
380
|
required_ruby_version: !ruby/object:Gem::Requirement
|
366
381
|
requirements:
|
367
|
-
- -
|
382
|
+
- - '>='
|
368
383
|
- !ruby/object:Gem::Version
|
369
384
|
version: 1.9.2
|
385
|
+
none: false
|
370
386
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
371
387
|
requirements:
|
372
|
-
- -
|
388
|
+
- - '>='
|
373
389
|
- !ruby/object:Gem::Version
|
374
390
|
version: '0'
|
391
|
+
none: false
|
375
392
|
requirements: []
|
376
|
-
rubyforge_project:
|
377
|
-
rubygems_version:
|
378
|
-
signing_key:
|
379
|
-
specification_version:
|
393
|
+
rubyforge_project:
|
394
|
+
rubygems_version: 1.8.24
|
395
|
+
signing_key:
|
396
|
+
specification_version: 3
|
380
397
|
summary: libuv bindings for Ruby
|
381
|
-
test_files:
|
382
|
-
|
398
|
+
test_files:
|
399
|
+
- spec/async_spec.rb
|
400
|
+
- spec/cpu_spec.rb
|
401
|
+
- spec/defer_spec.rb
|
402
|
+
- spec/filesystem_spec.rb
|
403
|
+
- spec/idle_spec.rb
|
404
|
+
- spec/pipe_spec.rb
|
405
|
+
- spec/tcp_spec.rb
|
406
|
+
has_rdoc:
|