oldmoe-reactor 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/reactor.rb +9 -3
- data/reactor.gemspec +2 -2
- metadata +2 -2
data/lib/reactor.rb
CHANGED
@@ -133,6 +133,7 @@ module Reactor
|
|
133
133
|
# mode can be either :read or :write
|
134
134
|
def detach(mode, io, force=false)
|
135
135
|
selectables = @selectables[mode] || raise("mode is not :read or :write")
|
136
|
+
return unless selectables[:ios].include?(io.object_id)
|
136
137
|
if !force && selectables[:callbacks][io.object_id].length > 1
|
137
138
|
selectables[:callbacks][io.object_id].shift
|
138
139
|
else
|
@@ -140,7 +141,7 @@ module Reactor
|
|
140
141
|
selectables[:callbacks].delete(io.object_id)
|
141
142
|
selectables[:dirty] = true
|
142
143
|
end
|
143
|
-
@on_detach.call(mode, io) if @
|
144
|
+
@on_detach.call(mode, io) if @on_detach
|
144
145
|
end
|
145
146
|
|
146
147
|
# Supply a callback to on_detach that will be called
|
@@ -162,7 +163,7 @@ module Reactor
|
|
162
163
|
#
|
163
164
|
# mode can be either :read or :write
|
164
165
|
def attached?(mode, io)
|
165
|
-
@selectables[mode][:ios].include? io
|
166
|
+
@selectables[mode][:ios].include? io.object_id
|
166
167
|
end
|
167
168
|
|
168
169
|
# Add a block of code that will fire after some time
|
@@ -215,7 +216,12 @@ module Reactor
|
|
215
216
|
end
|
216
217
|
|
217
218
|
def fire_ios(mode, ios)
|
218
|
-
ios.each
|
219
|
+
ios.each do |io|
|
220
|
+
# an io might get detached while we are in this loop
|
221
|
+
# so we just ignore it
|
222
|
+
callback = @selectables[mode][:callbacks][io.object_id]
|
223
|
+
callback[0].call(io, self) if callback
|
224
|
+
end
|
219
225
|
end
|
220
226
|
end
|
221
227
|
end
|
data/reactor.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "reactor"
|
3
|
-
s.version = "0.2.
|
4
|
-
s.date = "2009-07-
|
3
|
+
s.version = "0.2.3"
|
4
|
+
s.date = "2009-07-10"
|
5
5
|
s.summary = "A pure Ruby reactor library"
|
6
6
|
s.email = "oldmoe@gmail.com"
|
7
7
|
s.homepage = "http://github.com/oldmoe/reactor"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oldmoe-reactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muhammad A. Ali
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-10 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|