async-io 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/io.rb +0 -8
- data/lib/async/io/endpoint.rb +17 -9
- data/lib/async/io/generic.rb +5 -0
- data/lib/async/io/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c21728ab9008e3a380403814866827866f69cfa5
|
4
|
+
data.tar.gz: 9459dcb16dc458acf1724865b12a53dccf548dc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60deebccccfc2885880c6a226b8f7637ec1234894efc92cc125e04778555a65f69e4dac73547c0e11de360c575830258fb32093353109bd08fe6cc351d404b6d
|
7
|
+
data.tar.gz: 43de7fec9b8046f1b6fbb7be981671879d2f2ad7479d791a651b1aad82301edb834a64de0d7d66e4059f8111f2bc8b899970ff8f17c26da55e00806f04546fcb
|
data/lib/async/io.rb
CHANGED
data/lib/async/io/endpoint.rb
CHANGED
@@ -61,8 +61,12 @@ module Async
|
|
61
61
|
yield self.send(*specification)
|
62
62
|
elsif specification.is_a? String
|
63
63
|
yield self.parse(specification)
|
64
|
+
elsif specification.is_a? ::BasicSocket
|
65
|
+
yield SocketEndpoint.new(specification)
|
66
|
+
elsif specification.is_a? Generic
|
67
|
+
yield Endpoint.new(specification)
|
64
68
|
else
|
65
|
-
|
69
|
+
raise ArgumentError.new("Not sure how to convert #{specification} to endpoint!")
|
66
70
|
end
|
67
71
|
end
|
68
72
|
end
|
@@ -72,6 +76,10 @@ module Async
|
|
72
76
|
super(specification, options)
|
73
77
|
end
|
74
78
|
|
79
|
+
def address
|
80
|
+
specification.local_address
|
81
|
+
end
|
82
|
+
|
75
83
|
def to_sockaddr
|
76
84
|
address.to_sockaddr
|
77
85
|
end
|
@@ -94,9 +102,9 @@ module Async
|
|
94
102
|
address.protocol
|
95
103
|
end
|
96
104
|
|
97
|
-
|
98
|
-
|
99
|
-
|
105
|
+
def bind
|
106
|
+
yield specification
|
107
|
+
end
|
100
108
|
|
101
109
|
def accept(&block)
|
102
110
|
backlog = self.options.fetch(:backlog, Socket::SOMAXCONN)
|
@@ -107,9 +115,9 @@ module Async
|
|
107
115
|
end
|
108
116
|
end
|
109
117
|
|
110
|
-
|
111
|
-
|
112
|
-
|
118
|
+
def connect
|
119
|
+
yield specification
|
120
|
+
end
|
113
121
|
end
|
114
122
|
|
115
123
|
# This class will open and close the socket automatically.
|
@@ -127,14 +135,14 @@ module Async
|
|
127
135
|
end
|
128
136
|
end
|
129
137
|
|
130
|
-
# This class doesn't exert ownership over the specified socket.
|
138
|
+
# This class doesn't exert ownership over the specified socket, wraps a native ::IO.
|
131
139
|
class SocketEndpoint < Endpoint
|
132
140
|
def address
|
133
141
|
specification.local_address
|
134
142
|
end
|
135
143
|
|
136
144
|
def bind(&block)
|
137
|
-
yield Socket.new(specification
|
145
|
+
yield Socket.new(specification)
|
138
146
|
end
|
139
147
|
|
140
148
|
def connect(&block)
|
data/lib/async/io/generic.rb
CHANGED
@@ -23,6 +23,11 @@ require 'forwardable'
|
|
23
23
|
|
24
24
|
module Async
|
25
25
|
module IO
|
26
|
+
# Convert a Ruby ::IO object to a wrapped instance:
|
27
|
+
def self.try_convert(io, &block)
|
28
|
+
Generic::WRAPPERS[io.class].wrap(io, &block)
|
29
|
+
end
|
30
|
+
|
26
31
|
# Represents an asynchronous IO within a reactor.
|
27
32
|
class Generic < Wrapper
|
28
33
|
extend Forwardable
|
data/lib/async/io/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|