io-event 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9138d171a26780a13bfb5e983488d743de8e891112e976d02f10a73fedace606
4
- data.tar.gz: 0e4c44a7f8f1379fc8de5dd3fa8ffde0bd4f6bffc1bdb25a0fb7cfb0dfd45bc7
3
+ metadata.gz: 2df9208cf2ad89251afc206b4c3e2c9be1385db65b6723238bc00350ef19e4f5
4
+ data.tar.gz: d4e487b9004f5c44be24d548a0eb35614b652e1782186748f3ead31e2755d0b4
5
5
  SHA512:
6
- metadata.gz: 733f4341efdf63775b2faac16609a3f8574a2d17a77db919375afd04bbaa0730acca6fd6dc9849a4aa4177fbe8b9d2855afabbf64e5e31e8ce09ae8f0f6e46bc
7
- data.tar.gz: a207ab4ef7a2097189f2e59fe4838a5aa877856a0b3ac9732b19340ffbd8ef73460aca159794dfaa3e488b9436fb614fccabd94151290a02e70e6f43281a754f
6
+ metadata.gz: 80c84b174c3adbc88004e02d451f01016e5c4ac2ca1e0fc1a7b75b49922078de4c16816fe4685e5ab79c1bfb1816eb2dcf61cb513f9637b0f153d76ad538816d
7
+ data.tar.gz: 50845ffdb59deb510caaaf94e8a62ef64729e5a69a31b57621d022f1186dc8c68d14ca4a0d20b3413716c0aa8e547c085627aa6d1f45371681d445d9a63ef95a
@@ -104,7 +104,7 @@ module IO::Event
104
104
  private
105
105
 
106
106
  def register_readable(fiber, io, events)
107
- if (events & READABLE) > 0
107
+ if (events & IO::READABLE) > 0
108
108
  if @readable.key?(io)
109
109
  raise "Cannot wait for #{io} to become readable from multiple fibers."
110
110
  end
@@ -122,7 +122,7 @@ module IO::Event
122
122
  end
123
123
 
124
124
  def register_writable(fiber, io, events)
125
- if (events & WRITABLE) > 0
125
+ if (events & IO::WRITABLE) > 0
126
126
  if @writable.key?(io)
127
127
  raise "Cannot wait for #{io} to become writable from multiple fibers."
128
128
  end
@@ -140,7 +140,7 @@ module IO::Event
140
140
  end
141
141
 
142
142
  def register_priority(fiber, io, events)
143
- if (events & PRIORITY) > 0
143
+ if (events & IO::PRIORITY) > 0
144
144
  if @priority.key?(io)
145
145
  raise "Cannot wait for #{io} to become priority from multiple fibers."
146
146
  end
@@ -18,8 +18,6 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require_relative 'selector'
22
-
23
21
  module IO::Event
24
22
  # A thread safe synchronisation primative.
25
23
  class Interrupt
@@ -33,7 +31,7 @@ module IO::Event
33
31
 
34
32
  @fiber = Fiber.new do
35
33
  while true
36
- if @selector.io_wait(@fiber, @input, READABLE)
34
+ if @selector.io_wait(@fiber, @input, IO::READABLE)
37
35
  @input.read_nonblock(1)
38
36
  end
39
37
  end
@@ -112,12 +112,12 @@ module IO::Event
112
112
  def io_wait(fiber, io, events)
113
113
  remove_readable = remove_writable = false
114
114
 
115
- if (events & READABLE) > 0 or (events & PRIORITY) > 0
115
+ if (events & IO::READABLE) > 0 or (events & IO::PRIORITY) > 0
116
116
  @readable[io] = fiber
117
117
  remove_readable = true
118
118
  end
119
119
 
120
- if (events & WRITABLE) > 0
120
+ if (events & IO::WRITABLE) > 0
121
121
  @writable[io] = fiber
122
122
  remove_writable = true
123
123
  end
@@ -138,9 +138,9 @@ module IO::Event
138
138
 
139
139
  case result = io.read_nonblock(maximum_size, exception: false)
140
140
  when :wait_readable
141
- self.io_wait(fiber, io, READABLE)
141
+ self.io_wait(fiber, io, IO::READABLE)
142
142
  when :wait_writable
143
- self.io_wait(fiber, io, WRITABLE)
143
+ self.io_wait(fiber, io, IO::WRITABLE)
144
144
  else
145
145
  break unless result
146
146
 
@@ -162,9 +162,9 @@ module IO::Event
162
162
  chunk = buffer.to_str(offset, length)
163
163
  case result = io.write_nonblock(chunk, exception: false)
164
164
  when :wait_readable
165
- self.io_wait(fiber, io, READABLE)
165
+ self.io_wait(fiber, io, IO::READABLE)
166
166
  when :wait_writable
167
- self.io_wait(fiber, io, WRITABLE)
167
+ self.io_wait(fiber, io, IO::WRITABLE)
168
168
  else
169
169
  offset += result
170
170
  length -= result
@@ -184,7 +184,7 @@ module IO::Event
184
184
  w.close
185
185
  end
186
186
 
187
- self.io_wait(fiber, r, READABLE)
187
+ self.io_wait(fiber, r, IO::READABLE)
188
188
 
189
189
  return thread.value
190
190
  ensure
@@ -221,12 +221,12 @@ module IO::Event
221
221
 
222
222
  readable&.each do |io|
223
223
  fiber = @readable.delete(io)
224
- ready[fiber] |= READABLE
224
+ ready[fiber] |= IO::READABLE
225
225
  end
226
226
 
227
227
  writable&.each do |io|
228
228
  fiber = @writable.delete(io)
229
- ready[fiber] |= WRITABLE
229
+ ready[fiber] |= IO::WRITABLE
230
230
  end
231
231
 
232
232
  ready.each do |fiber, events|
@@ -21,11 +21,6 @@
21
21
  require_relative 'selector/select'
22
22
 
23
23
  module IO::Event
24
- # These constants are the same as those defined in IO.
25
- READABLE = IO::READABLE
26
- PRIORITY = IO::PRIORITY
27
- WRITABLE = IO::WRITABLE
28
-
29
24
  module Selector
30
25
  def self.default(env = ENV)
31
26
  if name = env['IO_EVENT_SELECTOR']&.to_sym
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module IO::Event
22
- VERSION = "0.2.0"
22
+ VERSION = "0.2.1"
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-event
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams